diff options
| author | ame <[email protected]> | 2024-05-07 14:09:48 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2024-05-07 14:09:48 -0500 |
| commit | 3200f04de946049e950c6f7fd1e9d4d2f599c9ea (patch) | |
| tree | 68a9e2f5e2f496fc630d036fd27f2aae9fb2ad23 /docs/thread.md | |
| parent | a571dd1ac9fc4d46e0bbc95a3ab88f52ee37b1a1 (diff) | |
more work on threads
Diffstat (limited to 'docs/thread.md')
| -rw-r--r-- | docs/thread.md | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/docs/thread.md b/docs/thread.md index aa34f5c..32df9c9 100644 --- a/docs/thread.md +++ b/docs/thread.md @@ -34,18 +34,23 @@ t:await() these have the same backend (and limitations) of network threads ```lua -local thread = llib.thread.async(function(info) +local thread = llib.thread.async(function(res, rej) local N = 0 ... - return N + res(N) end) ``` ### thread function parameters ** -as used with "info" above +as used with "res" above + +#### res:res() ** -#### info:send() ** +'takes any amount of "any" values + +send a value(s) to thread:await() call then stalls the thread until cleaned +#### res:send() ** 'takes "any" value @@ -56,22 +61,29 @@ info:send(5) info:send("hello") ``` -#### info:pause() ** - -pauses the thread (must be resumed from outside) - ### thread return object ** #### thread:await() ** -'optional timeout +'optional timeout in ms and boolean whether to keep or not -waits for the thread to return, and returns whatever it returned, if timeout is exceeded nil +waits for the thread to return, and returns whatever it returned then closes it, or nil if timeout was exceeded +if the input is the boolean value true, it will keep the thread alive (otherwise await() can not be called again) ```lua thread:await() -- value of N (above) ``` +```lua +thread:await(20) -- value of N (above) or nil +``` + +```lua +thread:await(true) -- value of N (above) +thread:await() -- same +thread:await() -- error, function above performed cleanup +``` + #### thread:next() ** gets the most oldest value sent using info:send() and pops it @@ -85,7 +97,3 @@ thread:next() -- "hello" #### thread:kill() ** kills the thread - -#### thread:pause() thread:resume() ** - -stops or continues the thread |
