aboutsummaryrefslogtreecommitdiff
path: root/docs/thread.md
diff options
context:
space:
mode:
authorame <[email protected]>2024-05-25 04:08:59 -0500
committerame <[email protected]>2024-05-25 04:08:59 -0500
commit237fcfbd61a9895326538a274f025d9ed57a3903 (patch)
tree44c36c7d38ae68f562a0290c26bae4a79ab87f1e /docs/thread.md
parent8d169e81694b587a425993cb11297e8a9183b37c (diff)
fixed deepcopy
Diffstat (limited to 'docs/thread.md')
-rw-r--r--docs/thread.md45
1 files changed, 45 insertions, 0 deletions
diff --git a/docs/thread.md b/docs/thread.md
index 9f868cb..00619ea 100644
--- a/docs/thread.md
+++ b/docs/thread.md
@@ -1,5 +1,50 @@
# threads **
+## buffer
+
+'takes 'anything'
+
+a thread-safe object buffer to easily transfer things between threads
+
+full example:
+
+```lua
+buffer = llib.thread.buffer({2, 3, 4})
+buffer:get() --{2, 3, 4}
+...
+buffer:set({3, 4, 5}) --get is now {3, 4, 5}
+...
+buffer:mod(function(obj)
+ for i=1,#obj do
+ obj[i] = obj[i] + 1
+ end
+ return obj
+end) --is now {4, 5, 6}
+...
+buffer:clean() -- calls __gc early
+```
+
+### get
+
+returns copy of the value in the buffer
+
+### set
+
+'takes 'anything'
+
+sets the value in the buffer
+
+### mod
+
+'takes a function, one parameter, one returns
+
+passes a copy of the value of the buffer, and sets the buffer to the value returned
+
+```lua
+buffer:mod(function(obj) return 5)
+--is the same as
+buffer:set(5)
+```
## lock, unlock
'takes an integer