diff options
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 | |||