diff options
| -rw-r--r-- | README.md | 22 |
1 files changed, 8 insertions, 14 deletions
| @@ -41,32 +41,26 @@ local thread = require "llthreads".new[[ | |||
| 41 | require "utils".sleep(5) | 41 | require "utils".sleep(5) |
| 42 | ]] | 42 | ]] |
| 43 | 43 | ||
| 44 | -- We tell that we start atached thread | 44 | -- We tell that we start atached thread but child Lua State shuld be close in child thread. |
| 45 | -- but child Lua State shuld be close | 45 | -- So thread:join() can not return any Lua values. |
| 46 | -- in child thread. | 46 | -- If `thread` became garbage in main thread then finallizer calls thread:join() |
| 47 | -- So thread:join() can not return any values. | 47 | -- and main thread may hungup. |
| 48 | -- If `thread` became garbage in main thread then | ||
| 49 | -- finallizer calls thread:join() and main thread | ||
| 50 | -- may hungup. | ||
| 51 | thread:start(false, false) | 48 | thread:start(false, false) |
| 52 | 49 | ||
| 53 | -- we can call join | 50 | -- we can call join |
| 54 | thread:join() | 51 | thread:join() |
| 55 | ``` | 52 | ``` |
| 56 | 53 | ||
| 57 | ### Start detached thread collectd on which we can call join | 54 | ### Start detached thread on which we can call join |
| 58 | ``` Lua | 55 | ``` Lua |
| 59 | -- This is main thread. | 56 | -- This is main thread. |
| 60 | local thread = require "llthreads".new[[ | 57 | local thread = require "llthreads".new[[ |
| 61 | require "utils".sleep(5) | 58 | require "utils".sleep(5) |
| 62 | ]] | 59 | ]] |
| 63 | 60 | ||
| 64 | -- We tell that we start detached thread | 61 | -- We tell that we start detached thread but with ability call thread:join() and |
| 65 | -- but with ability call thread:join() | 62 | -- gets lua return values from child thread. In fact we start atached thread but if `thread` |
| 66 | -- and gets lua return values from child thread. | 63 | -- became garbage in main thread then finallizer just detach child thread and main 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. | 64 | -- may not hungup. |
| 71 | thread:start(true, true) | 65 | thread:start(true, true) |
| 72 | 66 | ||
