diff options
-rw-r--r-- | README.md | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -20,6 +20,15 @@ This is full dropin replacement for [llthreads](https://github.com/Neopallium/lu | |||
20 | * thread:start() has additional parameter which control in which thread child Lua VM will be destroyed | 20 | * thread:start() has additional parameter which control in which thread child Lua VM will be destroyed |
21 | * allow pass cfunctions to child thread (e.g. to initialize Lua state) | 21 | * allow pass cfunctions to child thread (e.g. to initialize Lua state) |
22 | 22 | ||
23 | ##Thread start arguments | ||
24 | | default | `detached` | `joinable` | join returns | child state closes by | gc calls | detach on | | ||
25 | |:-------:|:--------:|:--------:|:------------:|:------------------:|:--------:|:---------:| | ||
26 | | | false | false | `true` | child | join | `<NEVER>` | | ||
27 | | * | false | true | Lua values | parent | join | `<NEVER>` | | ||
28 | | * | true | false | raise error | child | `<NONE>` | start | | ||
29 | | | true | true | `true` | child | detach | gc | | ||
30 | |||
31 | |||
23 | ##Usage | 32 | ##Usage |
24 | 33 | ||
25 | ### Use custom logger | 34 | ### Use custom logger |
@@ -45,7 +54,8 @@ local thread = require "llthreads".new[[ | |||
45 | 54 | ||
46 | -- We tell that we start attached thread but child Lua State shuld be close in child thread. | 55 | -- We tell that we start attached thread but child Lua State shuld be close in child thread. |
47 | -- If `thread` became garbage in main thread then finallizer calls thread:join() | 56 | -- If `thread` became garbage in main thread then finallizer calls thread:join() |
48 | -- and main thread may hungup. | 57 | -- and main thread may hungup. But because of child state closes in child thread all objects |
58 | -- in this state can be destroyed and we can prevent deadlock. | ||
49 | thread:start(false, false) | 59 | thread:start(false, false) |
50 | 60 | ||
51 | -- We can call join. | 61 | -- We can call join. |