aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlexey Melnichuk <mimir@newmail.ru>2014-02-04 11:06:17 +0400
committerAlexey Melnichuk <mimir@newmail.ru>2014-02-04 11:06:17 +0400
commitcef9a7a112a8322e2c6498021df59e4a8f7b5246 (patch)
tree5a885427afef52cbd3067c79b1f24406e42ecf87 /test
parentd35bf824e0dd9c3584d1587b5ec662a0fcf71bfe (diff)
downloadlua-llthreads2-cef9a7a112a8322e2c6498021df59e4a8f7b5246.tar.gz
lua-llthreads2-cef9a7a112a8322e2c6498021df59e4a8f7b5246.tar.bz2
lua-llthreads2-cef9a7a112a8322e2c6498021df59e4a8f7b5246.zip
Add. `thread:alive()` method.
Diffstat (limited to 'test')
-rw-r--r--test/test_alive.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_alive.lua b/test/test_alive.lua
new file mode 100644
index 0000000..ecce163
--- /dev/null
+++ b/test/test_alive.lua
@@ -0,0 +1,35 @@
1local llthreads = require"llthreads"
2local utils = require "utils"
3local sleep = utils.sleep
4
5local include = utils.thread_init .. [[
6local llthreads = require"llthreads"
7local sleep = require "utils".sleep
8]]
9
10local thread = llthreads.new(include .. [[
11 sleep(5)
12 return 1,2,3
13]])
14
15assert(nil == thread:alive())
16
17thread:start()
18
19assert(true == thread:alive())
20
21for i = 1, 10 do
22 if not thread:alive() then break end
23 sleep(1)
24end
25
26assert(false == thread:alive())
27
28local ok,a,b,c = thread:join(0)
29assert(ok == true)
30assert(a == 1)
31assert(b == 2)
32assert(c == 3)
33
34print("Done!")
35