diff options
| author | Benoit Germain <bnt.germain@gmail.com> | 2011-03-01 21:12:56 +0100 |
|---|---|---|
| committer | Benoit Germain <bnt.germain@gmail.com> | 2011-03-01 21:12:56 +0100 |
| commit | e97adefde985e30fe31ffa036c74ffb0ce10ca26 (patch) | |
| tree | 4465decc5f07e7399f9760d6302dbaf7163120d7 /tests | |
| parent | 974aa4343cf900938b5d357d10798d91faf60f5a (diff) | |
| download | lanes-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.lua | 45 |
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 @@ | |||
| 1 | require "lanes" | ||
| 2 | |||
| 3 | -- create a free-running lane | ||
| 4 | |||
| 5 | local linda = lanes.linda() | ||
| 6 | |||
| 7 | local f = function( _linda) | ||
| 8 | _linda:receive("oy") | ||
| 9 | end | ||
| 10 | |||
| 11 | local g = function() | ||
| 12 | local cancelled | ||
| 13 | repeat | ||
| 14 | cancelled = cancel_test() | ||
| 15 | until cancelled | ||
| 16 | print "User cancellation detected!" | ||
| 17 | end | ||
| 18 | |||
| 19 | local genF = lanes.gen( "", {globals = {threadName = "mylane"}}, f) | ||
| 20 | local genG = lanes.gen( "", g) | ||
| 21 | |||
| 22 | |||
| 23 | -- launch a good batch of free running lanes | ||
| 24 | for 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 | --]] | ||
| 41 | end | ||
| 42 | |||
| 43 | print "exiting" | ||
| 44 | |||
| 45 | -- let process end terminate them and see what happens \ No newline at end of file | ||
