diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 18 |
1 files changed, 18 insertions, 0 deletions
| @@ -13,6 +13,7 @@ This is full dropin replacement for [llthreads](https://github.com/Neopallium/lu | |||
| 13 | ##Additional | 13 | ##Additional |
| 14 | * thread:join() method support zero timeout to check if thread alive (does not work on Windows with pthreads) | 14 | * thread:join() method support zero timeout to check if thread alive (does not work on Windows with pthreads) |
| 15 | * thread:join() method support arbitrary timeout on Windows threads | 15 | * thread:join() method support arbitrary timeout on Windows threads |
| 16 | * thread:alive() method return whether the thread is alive (does not work on Windows with pthreads) | ||
| 16 | * set_logger function allow logging errors (crash Lua VM) in current llthread's threads | 17 | * set_logger function allow logging errors (crash Lua VM) in current llthread's threads |
| 17 | * thread:start() has additional parameter which control in which thread child Lua VM will be destroyed | 18 | * thread:start() has additional parameter which control in which thread child Lua VM will be destroyed |
| 18 | * allow pass cfunctions to child thread (e.g. to initialize Lua state) | 19 | * allow pass cfunctions to child thread (e.g. to initialize Lua state) |
| @@ -89,5 +90,22 @@ llthreads.new([[ | |||
| 89 | ]], preload):start(true) | 90 | ]], preload):start(true) |
| 90 | ``` | 91 | ``` |
| 91 | 92 | ||
| 93 | ### Wait while thread is alive | ||
| 94 | ``` Lua | ||
| 95 | local thread = require "llthreads".new[[ | ||
| 96 | require "utils".sleep(5) | ||
| 97 | return 1 | ||
| 98 | ]] | ||
| 99 | thread:start() | ||
| 100 | |||
| 101 | -- we can not use `thread:join(0)` because we can not call it twice | ||
| 102 | -- so all returned vaules will be lost | ||
| 103 | while thread:alive() do | ||
| 104 | -- do some work | ||
| 105 | end | ||
| 106 | |||
| 107 | local ok, ret = thread:join() -- true, 1 | ||
| 108 | ``` | ||
| 109 | |||
| 92 | [](https://bitdeli.com/free "Bitdeli Badge") | 110 | [](https://bitdeli.com/free "Bitdeli Badge") |
| 93 | 111 | ||
