diff options
| author | moteus <mimir@newmail.ru> | 2013-12-26 18:52:58 +0400 |
|---|---|---|
| committer | moteus <mimir@newmail.ru> | 2013-12-26 18:52:58 +0400 |
| commit | e3fe5123a36643634e00de6a1bb940e6e1febade (patch) | |
| tree | 8eecc3aa10e8c6842efe1d798758942f35f555f6 /test/test_join_detach.lua | |
| parent | 5291caae5be68250a4d9aafa54fe2081ab2a6113 (diff) | |
| download | lua-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 'test/test_join_detach.lua')
| -rw-r--r-- | test/test_join_detach.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test_join_detach.lua b/test/test_join_detach.lua new file mode 100644 index 0000000..dd3ef11 --- /dev/null +++ b/test/test_join_detach.lua | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | local llthreads = require"llthreads" | ||
| 2 | local utils = require "utils" | ||
| 3 | |||
| 4 | do | ||
| 5 | |||
| 6 | local thread = llthreads.new(utils.thread_init .. [[ | ||
| 7 | local sleep = require"utils".sleep | ||
| 8 | while true do sleep(1) end | ||
| 9 | ]]) | ||
| 10 | |||
| 11 | -- detached + joindable | ||
| 12 | thread:start(true, true) | ||
| 13 | |||
| 14 | local ok, err = thread:join(0) | ||
| 15 | print("thread:join(0): ", ok, err) | ||
| 16 | assert(ok == nil) | ||
| 17 | assert(err == "timeout") | ||
| 18 | |||
| 19 | end | ||
| 20 | |||
| 21 | -- enforce collect `thread` object | ||
| 22 | -- we should not hungup | ||
| 23 | for i = 1, 10 do collectgarbage("collect") end | ||
| 24 | |||
| 25 | print("Done!") | ||
| 26 | |||
