diff options
| author | moteus <mimir@newmail.ru> | 2013-12-27 15:39:38 +0400 |
|---|---|---|
| committer | moteus <mimir@newmail.ru> | 2013-12-27 15:39:38 +0400 |
| commit | a26ecf383900e4c396958da80200cb2eb1121506 (patch) | |
| tree | be2909b271537c31e4b3973d89f02696712f2779 /test | |
| parent | bccb6bef9d7eb56eece7efa96524a5fea1eb8d73 (diff) | |
| download | lua-llthreads2-a26ecf383900e4c396958da80200cb2eb1121506.tar.gz lua-llthreads2-a26ecf383900e4c396958da80200cb2eb1121506.tar.bz2 lua-llthreads2-a26ecf383900e4c396958da80200cb2eb1121506.zip | |
Fix. detach joined thread.
Fix. try use child Lua state in join for detached thread.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_join_detach.lua | 28 |
1 files changed, 28 insertions, 0 deletions
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 | |||
| 22 | -- we should not hungup | 22 | -- we should not hungup |
| 23 | for i = 1, 10 do collectgarbage("collect") end | 23 | for i = 1, 10 do collectgarbage("collect") end |
| 24 | 24 | ||
| 25 | |||
| 26 | do | ||
| 27 | |||
| 28 | local thread = llthreads.new(utils.thread_init .. [[ | ||
| 29 | local sleep = require"utils".sleep | ||
| 30 | sleep(1) | ||
| 31 | ]]) | ||
| 32 | |||
| 33 | -- detached + joindable | ||
| 34 | thread:start(true, true) | ||
| 35 | |||
| 36 | local ok, err = thread:join(0) | ||
| 37 | print("thread:join(0): ", ok, err) | ||
| 38 | assert(ok == nil) | ||
| 39 | assert(err == "timeout") | ||
| 40 | |||
| 41 | utils.sleep(5) | ||
| 42 | local ok, err = thread:join(0) | ||
| 43 | print("thread:join(0): ", ok, err) | ||
| 44 | assert(ok) | ||
| 45 | |||
| 46 | end | ||
| 47 | |||
| 48 | -- enforce collect `thread` object | ||
| 49 | -- we should not get av | ||
| 50 | for i = 1, 10 do collectgarbage("collect") end | ||
| 51 | |||
| 52 | |||
| 25 | print("Done!") | 53 | print("Done!") |
| 26 | 54 | ||
