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 | |
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')
-rw-r--r-- | test/test_join_detach.lua | 26 | ||||
-rw-r--r-- | test/test_join_timeout.lua | 2 |
2 files changed, 27 insertions, 1 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 | |||
diff --git a/test/test_join_timeout.lua b/test/test_join_timeout.lua index 085497f..aa8f88d 100644 --- a/test/test_join_timeout.lua +++ b/test/test_join_timeout.lua | |||
@@ -14,7 +14,7 @@ local thread = llthreads.new(include .. [[ | |||
14 | thread:start() | 14 | thread:start() |
15 | local ok, err = thread:join(0) | 15 | local ok, err = thread:join(0) |
16 | print("thread:join(0): ", ok, err) | 16 | print("thread:join(0): ", ok, err) |
17 | assert(ok == false) | 17 | assert(ok == nil) |
18 | assert(err == "timeout") | 18 | assert(err == "timeout") |
19 | 19 | ||
20 | print("thread:join(): ", thread:join()) | 20 | print("thread:join(): ", thread:join()) |