summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authormoteus <mimir@newmail.ru>2013-12-26 18:52:58 +0400
committermoteus <mimir@newmail.ru>2013-12-26 18:52:58 +0400
commite3fe5123a36643634e00de6a1bb940e6e1febade (patch)
tree8eecc3aa10e8c6842efe1d798758942f35f555f6 /README.md
parent5291caae5be68250a4d9aafa54fe2081ab2a6113 (diff)
downloadlua-llthreads2-e3fe5123a36643634e00de6a1bb940e6e1febade.tar.gz
lua-llthreads2-e3fe5123a36643634e00de6a1bb940e6e1febade.tar.bz2
lua-llthreads2-e3fe5123a36643634e00de6a1bb940e6e1febade.zip
Add. `joinable` parameter to `start` method which control in which thread child Lua VM will be destroyed.
Diffstat (limited to 'README.md')
-rw-r--r--README.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/README.md b/README.md
index b14d44d..a5dc46e 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@ This is full dropin replacement for [llthreads](https://github.com/Neopallium/lu
16* thread:join() method support zero timeout to check if thread alive 16* thread:join() method support zero timeout to check if thread alive
17* thread:join() method support arbitrary timeout on Windows platform 17* thread:join() method support arbitrary timeout on Windows platform
18* set_logger function allow logging errors (crash Lua VM) in current llthread's threads 18* set_logger function allow logging errors (crash Lua VM) in current llthread's threads
19* thread:start() has additional parameter which control in which thread child Lua VM will be destroyed
19 20
20##Usage 21##Usage
21 22
@@ -33,5 +34,45 @@ llthread.set_logger(function(msg) LOG.error(msg) end)
33error("SOME ERROR") 34error("SOME ERROR")
34``` 35```
35 36
37### Start atached thread collectd in child thread
38``` Lua
39-- This is main thread.
40local thread = require "llthreads".new[[
41 require "utils".sleep(5)
42]]
43
44-- We tell that we start atached thread
45-- but child Lua State shuld be close
46-- in child thread.
47-- So thread:join() can not return any values.
48-- If `thread` became garbage in main thread then
49-- finallizer calls thread:join() and main thread
50-- may hungup.
51thread:start(false, false)
52
53-- we can call join
54thread:join()
55```
56
57### Start detached thread collectd on which we can call join
58``` Lua
59-- This is main thread.
60local thread = require "llthreads".new[[
61 require "utils".sleep(5)
62]]
63
64-- We tell that we start detached thread
65-- but with ability call thread:join()
66-- and gets lua return values from child thread.
67-- In fact we start atached thread but if `thread`
68-- became garbage in main thread then finallizer
69-- just detach child thread and main thread
70-- may not hungup.
71thread:start(true, true)
72
73-- we can call join
74thread:join()
75```
76
36[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moteus/lua-llthreads2/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 77[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/moteus/lua-llthreads2/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
37 78