summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAlexey Melnichuk <mimir@newmail.ru>2014-02-04 11:06:17 +0400
committerAlexey Melnichuk <mimir@newmail.ru>2014-02-04 11:06:17 +0400
commitcef9a7a112a8322e2c6498021df59e4a8f7b5246 (patch)
tree5a885427afef52cbd3067c79b1f24406e42ecf87 /README.md
parentd35bf824e0dd9c3584d1587b5ec662a0fcf71bfe (diff)
downloadlua-llthreads2-cef9a7a112a8322e2c6498021df59e4a8f7b5246.tar.gz
lua-llthreads2-cef9a7a112a8322e2c6498021df59e4a8f7b5246.tar.bz2
lua-llthreads2-cef9a7a112a8322e2c6498021df59e4a8f7b5246.zip
Add. `thread:alive()` method.
Diffstat (limited to 'README.md')
-rw-r--r--README.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/README.md b/README.md
index ba38ebd..66e4d8b 100644
--- a/README.md
+++ b/README.md
@@ -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
95local thread = require "llthreads".new[[
96 require "utils".sleep(5)
97 return 1
98]]
99thread: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
103while thread:alive() do
104 -- do some work
105end
106
107local ok, ret = thread:join() -- true, 1
108```
109
92[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moteus/lua-llthreads2/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 110[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moteus/lua-llthreads2/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
93 111