blob: 0d968090870462eee80ee03e105619e137e65fe7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
|