From a26ecf383900e4c396958da80200cb2eb1121506 Mon Sep 17 00:00:00 2001 From: moteus Date: Fri, 27 Dec 2013 15:39:38 +0400 Subject: Fix. detach joined thread. Fix. try use child Lua state in join for detached thread. --- test/test_join_detach.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') diff --git a/test/test_join_detach.lua b/test/test_join_detach.lua index dd3ef11..329fb27 100644 --- a/test/test_join_detach.lua +++ b/test/test_join_detach.lua @@ -22,5 +22,33 @@ end -- we should not hungup for i = 1, 10 do collectgarbage("collect") end + +do + +local thread = llthreads.new(utils.thread_init .. [[ + local sleep = require"utils".sleep + sleep(1) +]]) + +-- detached + joindable +thread:start(true, true) + +local ok, err = thread:join(0) +print("thread:join(0): ", ok, err) +assert(ok == nil) +assert(err == "timeout") + +utils.sleep(5) +local ok, err = thread:join(0) +print("thread:join(0): ", ok, err) +assert(ok) + +end + +-- enforce collect `thread` object +-- we should not get av +for i = 1, 10 do collectgarbage("collect") end + + print("Done!") -- cgit v1.2.3-55-g6feb