aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2011-03-01 21:12:56 +0100
committerBenoit Germain <bnt.germain@gmail.com>2011-03-01 21:12:56 +0100
commite97adefde985e30fe31ffa036c74ffb0ce10ca26 (patch)
tree4465decc5f07e7399f9760d6302dbaf7163120d7 /tests
parent974aa4343cf900938b5d357d10798d91faf60f5a (diff)
downloadlanes-e97adefde985e30fe31ffa036c74ffb0ce10ca26.tar.gz
lanes-e97adefde985e30fe31ffa036c74ffb0ce10ca26.tar.bz2
lanes-e97adefde985e30fe31ffa036c74ffb0ce10ca26.zip
* fixed potential crash at application shutdown when calling lua_close() on a killed thread's VM.
* exposed cancel_test() in the lanes to enable manual testing for cancellation requests. * removed kludgy {globals={threadName}} support, replaced with a new function set_debug_threadname().
Diffstat (limited to 'tests')
-rw-r--r--tests/atexit.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/atexit.lua b/tests/atexit.lua
new file mode 100644
index 0000000..fb4f34a
--- /dev/null
+++ b/tests/atexit.lua
@@ -0,0 +1,45 @@
1require "lanes"
2
3-- create a free-running lane
4
5local linda = lanes.linda()
6
7local f = function( _linda)
8 _linda:receive("oy")
9end
10
11local g = function()
12 local cancelled
13 repeat
14 cancelled = cancel_test()
15 until cancelled
16 print "User cancellation detected!"
17end
18
19local genF = lanes.gen( "", {globals = {threadName = "mylane"}}, f)
20local genG = lanes.gen( "", g)
21
22
23-- launch a good batch of free running lanes
24for i = 1, 10 do
25 -- if i%50 == 0 then print( i) end
26 local h = genF( linda)
27 local status
28 repeat
29 status = h.status
30 --print( status)
31 until status == "waiting"
32
33 -- [[
34 local h = genG()
35 local status
36 repeat
37 status = h.status
38 --print( status)
39 until status == "running"
40 --]]
41end
42
43print "exiting"
44
45-- let process end terminate them and see what happens \ No newline at end of file