From a571dd1ac9fc4d46e0bbc95a3ab88f52ee37b1a1 Mon Sep 17 00:00:00 2001 From: ame Date: Fri, 3 May 2024 13:40:55 -0500 Subject: starting threads and deep copy metatables --- docs/thread.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/thread.md b/docs/thread.md index 6a3b19d..aa34f5c 100644 --- a/docs/thread.md +++ b/docs/thread.md @@ -1,16 +1,43 @@ # threads ** -## llib.thread ** +## lock, unlock** + +'takes an integer + +locks any other thread reaching this lock id until a corresponding unlock is met + +```lua +llib.thread.lock(5) +... +llib.thread.unlock(5) +``` + +more indepth + +```lua +local t = llib.thread.async(function(info) + ... + llib.thread.lock(5) + ... + return N +end) + +... +llib.thread.unlock(5) +t:await() +``` + +## aync ** '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 thread = llib.thread.async(function(info) local N = 0 ... - return N; + return N end) ``` -- cgit v1.2.3