aboutsummaryrefslogtreecommitdiff
path: root/library/lullaby/thread.lua
diff options
context:
space:
mode:
Diffstat (limited to 'library/lullaby/thread.lua')
-rw-r--r--library/lullaby/thread.lua46
1 files changed, 34 insertions, 12 deletions
diff --git a/library/lullaby/thread.lua b/library/lullaby/thread.lua
index 6015a0b..43e897d 100644
--- a/library/lullaby/thread.lua
+++ b/library/lullaby/thread.lua
@@ -16,18 +16,41 @@ function async.await(T) end
---@return nil
function async.clean(T) end
----stops the thread
+---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
+---stops the thread forcefully, may cause problems, likely not thread-safe
+---@param T async-table
+---@return nil
+function async.kill(T) end
+
---contains data for the thread
---@deprecated
---@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
@@ -51,21 +74,12 @@ 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
function thread.buffer(value) end
----locks any thread reaching this lock id until a corresponding unlock is met
----@param tid integer
----@return nil
-function thread.lock(tid) end
-
----unlocks a lock id
----@param tid integer
----@return nil
-function thread.unlock(tid) end
-
---@deprecated
function thread.testcopy() end
@@ -91,4 +105,12 @@ 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
+
+---puts the thread to sleep for N seconds
+---@param N number
+function thread.sleep(N) end
+
return thread