diff options
author | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-02-13 16:09:15 +0100 |
---|---|---|
committer | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-02-13 16:09:15 +0100 |
commit | 32ad991eb8c590472607d61e9a831d2ca9db05c5 (patch) | |
tree | 1e3920223e81a5970241f9687db9129d7ec7bb2e /tests | |
parent | c38429579de57d338e0a1c14a7ed7b4aa90e059a (diff) | |
download | lanes-32ad991eb8c590472607d61e9a831d2ca9db05c5.tar.gz lanes-32ad991eb8c590472607d61e9a831d2ca9db05c5.tar.bz2 lanes-32ad991eb8c590472607d61e9a831d2ca9db05c5.zip |
more fixes/tweaks about cancelled lindas
* bumped version to 3.8.5
* linda:limit() returns lanes.cancel_error on a limited linda
* lanes.genlock() and lanes.genatomic() support cancelled lindas by
returning lanes.cancel_error whenever appropriate
* fixed a possible Lua stack overflow when calling linda:dump()
* fixed cases where linda:send() and linda:receive() would not return
lanes.cancel_error when they should
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cancel.lua | 30 | ||||
-rw-r--r-- | tests/linda_perf.lua | 4 |
2 files changed, 32 insertions, 2 deletions
diff --git a/tests/cancel.lua b/tests/cancel.lua index a5f1dab..6429487 100644 --- a/tests/cancel.lua +++ b/tests/cancel.lua | |||
@@ -2,6 +2,33 @@ local lanes = require "lanes" .configure{ with_timers = false} | |||
2 | 2 | ||
3 | local linda = lanes.linda() | 3 | local linda = lanes.linda() |
4 | 4 | ||
5 | --#################################################################### | ||
6 | print "\n\n####################################################################\nbegin genlock & genatomic cancel test\n" | ||
7 | |||
8 | -- get a lock and a atomic operator | ||
9 | local lock = lanes.genlock( linda, "lock", 1) | ||
10 | local atomic = lanes.genatomic( linda, "atomic") | ||
11 | |||
12 | -- check that cancelled lindas give cancel_error as they should | ||
13 | linda:cancel() | ||
14 | assert( linda:get( "empty") == lanes.cancel_error) | ||
15 | assert( lanes.genlock( linda, "any", 1) == lanes.cancel_error) | ||
16 | assert( lanes.genatomic( linda, "any") == lanes.cancel_error) | ||
17 | |||
18 | -- check that lock and atomic functions return cancel_error if the linda was cancelled | ||
19 | assert( lock( 1) == lanes.cancel_error) | ||
20 | assert( lock( -1) == lanes.cancel_error) | ||
21 | assert( atomic( 1) == lanes.cancel_error) | ||
22 | |||
23 | -- reset the linda so that the other tests work | ||
24 | linda:cancel( "none") | ||
25 | linda:limit( "lock", -1) | ||
26 | linda:set( "lock") | ||
27 | linda:limit( "atomic", -1) | ||
28 | linda:set( "atomic") | ||
29 | |||
30 | --#################################################################### | ||
31 | |||
5 | local laneBody = function( timeout_) | 32 | local laneBody = function( timeout_) |
6 | set_finalizer( function( err, stk) | 33 | set_finalizer( function( err, stk) |
7 | if err == lanes.cancel_error then | 34 | if err == lanes.cancel_error then |
@@ -105,4 +132,7 @@ linda:cancel( "both") | |||
105 | print "wait 5s" | 132 | print "wait 5s" |
106 | linda:receive( 5, "yeah") | 133 | linda:receive( 5, "yeah") |
107 | 134 | ||
135 | --#################################################################### | ||
136 | |||
108 | print "\ndone" | 137 | print "\ndone" |
138 | |||
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index 1d92c8e..1a44d07 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua | |||
@@ -31,8 +31,8 @@ local batched = function( l, loop, batch) | |||
31 | print( val) | 31 | print( val) |
32 | end | 32 | end |
33 | 33 | ||
34 | local lane_eater_gen = lanes.gen( "*", eater) | 34 | local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater) |
35 | local lane_batched_gen = lanes.gen( "*", batched) | 35 | local lane_batched_gen = lanes.gen( "*", {priority = 3}, batched) |
36 | 36 | ||
37 | -- main thread writes data while a lane reads it | 37 | -- main thread writes data while a lane reads it |
38 | local function ziva( preloop, loop, batch) | 38 | local function ziva( preloop, loop, batch) |