This repository was archived by the owner on Jun 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
API Documentation
ColonelThirtyTwo edited this page Mar 12, 2013
·
1 revision
-
local thread = Threading.Thread(func, ...)
: Creates and starts a thread, and returns it.-
func
is the thread's main function (which must be compatible withstring.dump
) - The rest of the arguments are passed to
func
when the thread starts. Nil, number, boolean, and string values are copied. Cdata objects are passed as void* lightuserdata objects, which can be re-cast into the needed type by the thread.
-
-
thread:join([timeout])
: Waits for the thread to end.-
timeout
: Time, in seconds, to block before returning.nil
, the default, means wait forever.0
means do not block. - Returns up to two values:
true
if the thread completed without errors,false
andThreading.TIMEOUT
if the function returned due to the timeout limit being exceeded, orfalse
and a string error message if the thread exited with an error.
-
-
thread:destroy()
: Destroys the thread, terminating it if it is still running. Called implicitly when the thread is garbage collected.- Note that terminating a thread like this is usually unsafe, and should only be used as a last resort
-
local mutex = Threading.Mutex()
: Creates a new, unlocked mutex object and returns it -
mutex:lock([timeout])
: Tries to lock the mutex, blocking if it is locked by another thread.-
timeout
: Time, in seconds, to block before returning.nil
, the default, means wait forever.0
means do not block.
-
-
mutex:unlock()
: Unlocks the mutex. -
mutex:destroy()
: Destroys the mutex. This is called implicitly when garbage collected.