diff options
| author | ame <[email protected]> | 2024-05-25 04:08:59 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2024-05-25 04:08:59 -0500 |
| commit | 152b605c856112b074dc7b41651424c4170fc067 (patch) | |
| tree | 44c36c7d38ae68f562a0290c26bae4a79ab87f1e /docs/thread.md | |
| parent | ce5051ab905a1751effebb8658caf9ed15b2be62 (diff) | |
fixed deepcopy
Diffstat (limited to 'docs/thread.md')
| -rw-r--r-- | docs/thread.md | 45 |
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
|
