diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fifo.lua | 7 | ||||
-rw-r--r-- | tests/linda_perf.lua | 5 | ||||
-rw-r--r-- | tests/require.lua | 7 |
3 files changed, 13 insertions, 6 deletions
diff --git a/tests/fifo.lua b/tests/fifo.lua index b68d8a4..47db4c9 100644 --- a/tests/fifo.lua +++ b/tests/fifo.lua | |||
@@ -4,10 +4,9 @@ | |||
4 | -- Sample program for Lua Lanes | 4 | -- Sample program for Lua Lanes |
5 | -- | 5 | -- |
6 | 6 | ||
7 | local lanes = require "lanes" | 7 | local lanes = require "lanes".configure{shutdown_timeout=3,with_timers=true} |
8 | lanes.configure() | ||
9 | 8 | ||
10 | local linda= lanes.linda() | 9 | local linda= lanes.linda( "atom") |
11 | local atomic_inc= lanes.genatomic( linda, "FIFO_n" ) | 10 | local atomic_inc= lanes.genatomic( linda, "FIFO_n" ) |
12 | 11 | ||
13 | assert( atomic_inc()==1 ) | 12 | assert( atomic_inc()==1 ) |
@@ -46,3 +45,5 @@ print( B:receive( 2.0 ) ) | |||
46 | -- Note: A and B can be passed between threads, or used as upvalues | 45 | -- Note: A and B can be passed between threads, or used as upvalues |
47 | -- by multiple threads (other parts will be copied but the 'linda' | 46 | -- by multiple threads (other parts will be copied but the 'linda' |
48 | -- handle is shared userdata and will thus point to the single place) | 47 | -- handle is shared userdata and will thus point to the single place) |
48 | lanes.timer_lane:cancel() | ||
49 | lanes.timer_lane:join() \ No newline at end of file | ||
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index be582ce..ebe9eac 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua | |||
@@ -84,8 +84,10 @@ local tests = | |||
84 | { 4000000, 0, 21}, | 84 | { 4000000, 0, 21}, |
85 | { 4000000, 0, 44},]] | 85 | { 4000000, 0, 44},]] |
86 | } | 86 | } |
87 | print "tests #1" | ||
87 | for k, v in pairs( tests) do | 88 | for k, v in pairs( tests) do |
88 | local pre, loop, batch = v[1], v[2], v[3] | 89 | local pre, loop, batch = v[1], v[2], v[3] |
90 | print( "testing", pre, loop, batch) | ||
89 | print( pre, loop, batch, "duration = " .. ziva( pre, loop, batch)) | 91 | print( pre, loop, batch, "duration = " .. ziva( pre, loop, batch)) |
90 | end | 92 | end |
91 | 93 | ||
@@ -188,8 +190,11 @@ local tests2 = | |||
188 | { 4000000, 0, 21}, | 190 | { 4000000, 0, 21}, |
189 | { 4000000, 0, 44}, | 191 | { 4000000, 0, 44}, |
190 | } | 192 | } |
193 | |||
194 | print "tests #2" | ||
191 | for k, v in pairs( tests2) do | 195 | for k, v in pairs( tests2) do |
192 | local pre, loop, batch = v[1], v[2], v[3] | 196 | local pre, loop, batch = v[1], v[2], v[3] |
197 | print( "testing", pre, loop, batch) | ||
193 | print( pre, loop, batch, "duration = " .. ziva2( pre, loop, batch)) | 198 | print( pre, loop, batch, "duration = " .. ziva2( pre, loop, batch)) |
194 | end | 199 | end |
195 | 200 | ||
diff --git a/tests/require.lua b/tests/require.lua index 1d081b4..656a7dd 100644 --- a/tests/require.lua +++ b/tests/require.lua | |||
@@ -4,9 +4,10 @@ | |||
4 | -- Test that 'require' works from sublanes | 4 | -- Test that 'require' works from sublanes |
5 | -- | 5 | -- |
6 | lanes = require "lanes" | 6 | lanes = require "lanes" |
7 | lanes.configure() | 7 | lanes.configure{with_timers = false} |
8 | 8 | ||
9 | local function a_lane() | 9 | local function a_lane() |
10 | print "IN A LANE" | ||
10 | -- To require 'math' we still actually need to have it initialized for | 11 | -- To require 'math' we still actually need to have it initialized for |
11 | -- the lane. | 12 | -- the lane. |
12 | -- | 13 | -- |
@@ -15,7 +16,7 @@ local function a_lane() | |||
15 | assert( math.sqrt(4)==2 ) | 16 | assert( math.sqrt(4)==2 ) |
16 | 17 | ||
17 | assert( lanes==nil ) | 18 | assert( lanes==nil ) |
18 | local lanes = require "lanes".configure() | 19 | local lanes = require "lanes".configure{with_timers = false} |
19 | assert( lanes and lanes.gen ) | 20 | assert( lanes and lanes.gen ) |
20 | 21 | ||
21 | local h= lanes.gen( function() return 42 end ) () | 22 | local h= lanes.gen( function() return 42 end ) () |
@@ -24,7 +25,7 @@ local function a_lane() | |||
24 | return v==42 | 25 | return v==42 |
25 | end | 26 | end |
26 | 27 | ||
27 | local gen= lanes.gen( "math,package,string,table", a_lane ) | 28 | local gen= lanes.gen( "math,package,string,table", {package={}},a_lane ) |
28 | 29 | ||
29 | local h= gen() | 30 | local h= gen() |
30 | local ret= h[1] | 31 | local ret= h[1] |