aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorame <[email protected]>2024-05-07 14:09:48 -0500
committerame <[email protected]>2024-05-07 14:09:48 -0500
commit43f85a15884a344238e25c118768d36976ae783a (patch)
tree68a9e2f5e2f496fc630d036fd27f2aae9fb2ad23 /docs
parent618263f6f85d08bfd85d4f0376663aa1e2f58eac (diff)
more work on threads
Diffstat (limited to 'docs')
-rw-r--r--docs/thread.md36
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