diff options
| author | ame <[email protected]> | 2025-10-27 04:14:13 -0500 |
|---|---|---|
| committer | ame <[email protected]> | 2025-10-27 04:14:13 -0500 |
| commit | b1359c6e17a82f21ae996a7e137a1e6c6d8828b3 (patch) | |
| tree | ffebe3b5c48e8764a3184acbffdb06d69fad62b6 /docs/thread/buffer.md | |
| parent | c98e641ed9169cc09e6fe44c1bee2b28d5d694b2 (diff) | |
buffer docs and small buffer changed
Diffstat (limited to 'docs/thread/buffer.md')
| -rw-r--r-- | docs/thread/buffer.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/thread/buffer.md b/docs/thread/buffer.md new file mode 100644 index 0000000..e366a33 --- /dev/null +++ b/docs/thread/buffer.md @@ -0,0 +1,31 @@ +## buffer + +thread.buffer(V) + +a buffer is a container that allows a variable to be shared between threads & states in a thread safe manor. + +it is able to store 'anything' though lightuserdata will likely not work properly. poorly structured user data may retain some shared state with the original, which could cause some use-after-free in some really poor situations. providing a __copy metamethod will alleviate this issue (read more in readme.md) + +the __gc metamethod will be stripped from the original object and called when the buffer's __gc gets called. you should not reuse the original object after putting in a buffer for this reason. + +the __index metamethod will index any value that is not a buffer.* method on the original object (i will try not to add any more) + +every other metamethod will be replaced with a proxy to the metamethod in the copied object + +### buffer:get + +buffer:get() + +copies the value in the buffer to the current state + +### buffer:set + +buffer:set(V) + +sets the value in the buffer + +### buffer:mod + +buffer:mod(function(V)) + +takes a function with a single argument (the value), the return value of this will be the new value, if it is nil, the value will return unchanged |
