aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cancel.lua30
-rw-r--r--tests/linda_perf.lua4
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
3local linda = lanes.linda() 3local linda = lanes.linda()
4 4
5--####################################################################
6print "\n\n####################################################################\nbegin genlock & genatomic cancel test\n"
7
8-- get a lock and a atomic operator
9local lock = lanes.genlock( linda, "lock", 1)
10local atomic = lanes.genatomic( linda, "atomic")
11
12-- check that cancelled lindas give cancel_error as they should
13linda:cancel()
14assert( linda:get( "empty") == lanes.cancel_error)
15assert( lanes.genlock( linda, "any", 1) == lanes.cancel_error)
16assert( lanes.genatomic( linda, "any") == lanes.cancel_error)
17
18-- check that lock and atomic functions return cancel_error if the linda was cancelled
19assert( lock( 1) == lanes.cancel_error)
20assert( lock( -1) == lanes.cancel_error)
21assert( atomic( 1) == lanes.cancel_error)
22
23-- reset the linda so that the other tests work
24linda:cancel( "none")
25linda:limit( "lock", -1)
26linda:set( "lock")
27linda:limit( "atomic", -1)
28linda:set( "atomic")
29
30--####################################################################
31
5local laneBody = function( timeout_) 32local 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")
105print "wait 5s" 132print "wait 5s"
106linda:receive( 5, "yeah") 133linda:receive( 5, "yeah")
107 134
135--####################################################################
136
108print "\ndone" 137print "\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)
32end 32end
33 33
34local lane_eater_gen = lanes.gen( "*", eater) 34local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater)
35local lane_batched_gen = lanes.gen( "*", batched) 35local 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
38local function ziva( preloop, loop, batch) 38local function ziva( preloop, loop, batch)