aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorame <[email protected]>2024-05-01 14:02:05 -0500
committerame <[email protected]>2024-05-01 14:02:05 -0500
commit22473687abdbf45c86e837d636cde036845e8460 (patch)
treeb33eac843e4086e3968dda48ccaec5f0a0d2e1f9
parent921bade0eb0289374f201f4e788b0b83fa7acaa9 (diff)
thread roadmap
-rw-r--r--docs/net.md2
-rw-r--r--docs/readme.md4
-rw-r--r--docs/thread.md64
-rw-r--r--readme.md2
4 files changed, 69 insertions, 3 deletions
diff --git a/docs/net.md b/docs/net.md
index 2c8ca45..28a7070 100644
--- a/docs/net.md
+++ b/docs/net.md
@@ -1,6 +1,6 @@
# net
-## listen (PARTIALLY IMPLEMENTED)
+## listen (mostly IMPLEMENTED)
'takes a function with 1 argument and a integer for a port
diff --git a/docs/readme.md b/docs/readme.md
index 14859a5..9427403 100644
--- a/docs/readme.md
+++ b/docs/readme.md
@@ -14,11 +14,11 @@ which makes a global llib table
> llib = require "llib"
> ```
-the table has many subtables, with related function in them, you can view them like so
+the table has many subtables and functions, with related function in them, you can view them like so
```lua
llib.io.pprint(llib) --pprint is a part of the io module, pprint meaning pretty print
```
-all subtables have a corresponding file in this directory, with info on its functions
+all subtables and functions have a corresponding file in this directory on usage
diff --git a/docs/thread.md b/docs/thread.md
new file mode 100644
index 0000000..0d96809
--- /dev/null
+++ b/docs/thread.md
@@ -0,0 +1,64 @@
+# threads **
+
+## llib.thread **
+
+'takes a function which will be ran in a separate thread with a single parameter with thread info
+
+these have the same backend (and limitations) of network threads
+
+```lua
+local thread = llib.thread(function(info)
+ local N = 0
+ ...
+ return N;
+end)
+```
+
+### thread function parameters
+
+as used with "info" above
+
+#### info:send()
+
+'takes "any" value
+
+send a value which can be retrieved from outside the thread with thread:next()
+
+```lua
+info:send(5)
+info:send("hello")
+```
+
+#### info:pause()
+
+pauses the thread (must be resumed from outside)
+
+### thread return object
+
+#### thread:await()
+
+'optional timeout
+
+waits for the thread to return, and returns whatever it returned, if timeout is exceeded nil
+
+```lua
+thread:await() -- value of N (above)
+```
+
+#### thread:next()
+
+gets the most oldest value sent using info:send() and pops it
+
+```lua
+--(continued from above)
+thread:next() -- 5
+thread:next() -- "hello"
+```
+
+#### thread:kill()
+
+kills the thread
+
+#### thread:pause() thread:resume()
+
+stops or continues the thread
diff --git a/readme.md b/readme.md
index 9be2615..fcfca65 100644
--- a/readme.md
+++ b/readme.md
@@ -30,6 +30,8 @@ todo:
* thread-safe wrapper object
+* threads
+
----
# credits