diff options
| author | ame <[email protected]> | 2025-11-04 01:47:09 -0600 |
|---|---|---|
| committer | ame <[email protected]> | 2025-11-04 01:47:32 -0600 |
| commit | 5d88c4a2b80060290467d84033082f3af0c333b2 (patch) | |
| tree | 62d51c8510748187324f1a65742f5d7a2c0a4214 /library | |
| parent | c4f000153d2988e2011d68c1eb45a6a9b1927487 (diff) | |
thread testcancel and usleep
Diffstat (limited to 'library')
| -rw-r--r-- | library/lullaby/thread.lua | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/library/lullaby/thread.lua b/library/lullaby/thread.lua index 7a1888c..41444ff 100644 --- a/library/lullaby/thread.lua +++ b/library/lullaby/thread.lua @@ -16,7 +16,7 @@ function async.await(T) end ---@return nil function async.clean(T) end ----stops the thread, may be unavaliable on some systems (android) and will call async:kill instead +---waits for the thread to either call res:testcancel() or for it to exit ---@param T async-table ---@return nil function async.close(T) end @@ -31,8 +31,26 @@ function async.kill(T) end ---@type lightuserdata async._ = nil +---@class async-res-table +---@overload fun(a: any): nil +local asyncres = setmetatable({}, { + __call = function() end +}) + +---checks if the thread is being requested to close with thread:close() +---@param T async-res-table +---@return nil +function asyncres.testclose(T) end + +---calls res:testclose every line +---@param T async-res-table +---@return nil +function asyncres.autoclose(T) end +---@meta + ---@async ----@param fun fun(res: fun(...)): nil function to call, parameter will set a return value for the thread +---@nodiscard +---@param fun fun(res: async-res-table): nil function to call, parameter will set a return value for the thread, also contains methods for thread managment ---@return async-table function thread.async(fun) end @@ -56,6 +74,7 @@ function buffer.set(T, value) end ---@return nil function buffer.mod(T, fun) end +---@nodiscard ---puts a value into a atomic thread-safe buffer ---@param value any ---@return buffer-table @@ -86,4 +105,8 @@ function mutex.free(T) end ---@return mutex-table function thread.mutex() end +---puts the thread to sleep for N microseconds +---@param N integer +function thread.usleep(N) end + return thread |
