diff options
author | Alexey Melnichuk <mimir@newmail.ru> | 2014-02-11 17:32:59 +0400 |
---|---|---|
committer | Alexey Melnichuk <mimir@newmail.ru> | 2014-02-11 17:34:14 +0400 |
commit | d13929706a3b45bd64e0a87e0afc3d45625e888d (patch) | |
tree | d1c846805f127736d1dafb3b3094eaf78d032859 /llthreads2/test/test_alive.lua | |
parent | 46ed59584e5407c49a02f1ea6bede6487259a92e (diff) | |
download | lua-llthreads2-d13929706a3b45bd64e0a87e0afc3d45625e888d.tar.gz lua-llthreads2-d13929706a3b45bd64e0a87e0afc3d45625e888d.tar.bz2 lua-llthreads2-d13929706a3b45bd64e0a87e0afc3d45625e888d.zip |
Init LuaDist for llthreads2 module.
Diffstat (limited to 'llthreads2/test/test_alive.lua')
-rw-r--r-- | llthreads2/test/test_alive.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/llthreads2/test/test_alive.lua b/llthreads2/test/test_alive.lua new file mode 100644 index 0000000..ecce163 --- /dev/null +++ b/llthreads2/test/test_alive.lua | |||
@@ -0,0 +1,35 @@ | |||
1 | local llthreads = require"llthreads" | ||
2 | local utils = require "utils" | ||
3 | local sleep = utils.sleep | ||
4 | |||
5 | local include = utils.thread_init .. [[ | ||
6 | local llthreads = require"llthreads" | ||
7 | local sleep = require "utils".sleep | ||
8 | ]] | ||
9 | |||
10 | local thread = llthreads.new(include .. [[ | ||
11 | sleep(5) | ||
12 | return 1,2,3 | ||
13 | ]]) | ||
14 | |||
15 | assert(nil == thread:alive()) | ||
16 | |||
17 | thread:start() | ||
18 | |||
19 | assert(true == thread:alive()) | ||
20 | |||
21 | for i = 1, 10 do | ||
22 | if not thread:alive() then break end | ||
23 | sleep(1) | ||
24 | end | ||
25 | |||
26 | assert(false == thread:alive()) | ||
27 | |||
28 | local ok,a,b,c = thread:join(0) | ||
29 | assert(ok == true) | ||
30 | assert(a == 1) | ||
31 | assert(b == 2) | ||
32 | assert(c == 3) | ||
33 | |||
34 | print("Done!") | ||
35 | |||