Skip to content

Commit 593ff92

Browse files
committed
Tighten threading LuaLS overloads
1 parent 7f5a69f commit 593ff92

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎etc/threading.lua‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ local threading_thread = {}
122122
---@overload fun<R>(self: threading.thread<R>, timeout: number): true, R, ...
123123
---@overload fun<R>(self: threading.thread<R>, timeout: number): false, any
124124
---@overload fun<R>(self: threading.thread<R>, timeout: number): nil, threading.timeout_error
125-
---@param timeout? number seconds to wait; omit to block indefinitely.
125+
---@param timeout number seconds to wait when supplied.
126126
---@return threading.join_status ok true for child success, false for child error, nil on timeout.
127127
---@return ... child results, an error object, or the timeout reason.
128128
function threading_thread:join(timeout) end
@@ -173,8 +173,8 @@ local threading_channel = {}
173173
---@overload fun(self: threading.channel<T>, value: T, timeout: number): nil, threading.timeout_error
174174
---@param self threading.channel<T>
175175
---@param value T
176-
---@param timeout? number seconds to wait; omit to block indefinitely.
177-
---@return true|nil ok true on success, nil on timeout.
176+
---@param timeout number seconds to wait when supplied.
177+
---@return threading.send_result ok true on success, nil on timeout.
178178
---@return threading.timeout_error? err timeout reason when `ok` is nil.
179179
function threading_channel:send(value, timeout) end
180180

@@ -189,7 +189,7 @@ function threading_channel:send(value, timeout) end
189189
---@overload fun(self: threading.channel<T>, timeout: number): nil, false
190190
---@overload fun(self: threading.channel<T>, timeout: number): nil, threading.timeout_error
191191
---@param self threading.channel<T>
192-
---@param timeout? number seconds to wait; omit to block indefinitely.
192+
---@param timeout number seconds to wait when supplied.
193193
---@return T|nil value
194194
---@return threading.recv_status status
195195
function threading_channel:recv(timeout) end
@@ -231,7 +231,8 @@ function threading.now() end
231231
function threading.fence() end
232232

233233
---@overload fun(): nil
234-
---@param seconds? number seconds to sleep; omit to sleep for 0 seconds.
234+
---@overload fun(seconds: number): nil
235+
---@param seconds number seconds to sleep when supplied.
235236
---@return nil
236237
function threading.sleep(seconds) end
237238

@@ -241,11 +242,17 @@ function threading.sleep(seconds) end
241242
function threading.gcstats() end
242243

243244
---Query or set the number of parked GC2 worker threads.
245+
---@overload fun(): integer
246+
---@overload fun(count: nil): integer
247+
---@overload fun(count: integer): integer
244248
---@param count? integer|nil nil queries without changing the worker count.
245249
---@return integer old_count
246250
function threading.gcworkers(count) end
247251

248252
---Query or set the GC2 collection mode.
253+
---@overload fun(): threading.gcmode
254+
---@overload fun(mode: nil): threading.gcmode
255+
---@overload fun(mode: threading.gcmode): threading.gcmode
249256
---@param mode? threading.gcmode|nil nil queries without changing the mode.
250257
---@return threading.gcmode old_mode
251258
function threading.gcmode(mode) end
@@ -271,7 +278,7 @@ function threading.mutex() end
271278
---requested capacity.
272279
---@overload fun(): threading.channel<any>
273280
---@overload fun(capacity: integer): threading.channel<any>
274-
---@param capacity? integer buffered slot count; omit for a rendezvous channel.
281+
---@param capacity integer buffered slot count when supplied.
275282
---@return threading.channel<any> channel
276283
function threading.channel(capacity) end
277284

0 commit comments

Comments
 (0)