aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-03-22 15:36:45 +0100
committerBenoit Germain <benoit.germain@ubisoft.com>2024-03-22 15:36:45 +0100
commitbfb1277b3496018b7ee12eca2fb900ebbe651b49 (patch)
tree7909c38e5fc0c25ee0477c0b842e19adf0cd2874 /tests
parentf0170ce8f1a90337637d387b87280f121d0578fe (diff)
downloadlanes-bfb1277b3496018b7ee12eca2fb900ebbe651b49.tar.gz
lanes-bfb1277b3496018b7ee12eca2fb900ebbe651b49.tar.bz2
lanes-bfb1277b3496018b7ee12eca2fb900ebbe651b49.zip
C++ migration: STACK_GROW is no longer a macro, sanitized and fixed warnings in keeper.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/fifo.lua35
1 files changed, 29 insertions, 6 deletions
diff --git a/tests/fifo.lua b/tests/fifo.lua
index bef60d5..8bd1fc2 100644
--- a/tests/fifo.lua
+++ b/tests/fifo.lua
@@ -6,24 +6,27 @@
6 6
7local lanes = require "lanes".configure{shutdown_timeout=3,with_timers=true} 7local lanes = require "lanes".configure{shutdown_timeout=3,with_timers=true}
8 8
9local linda = lanes.linda( "atom") 9local atomic_linda = lanes.linda( "atom")
10local atomic_inc= lanes.genatomic( linda, "FIFO_n") 10local atomic_inc= lanes.genatomic( atomic_linda, "FIFO_n")
11
12local fifo_linda = lanes.linda( "fifo")
11 13
12assert( atomic_inc()==1) 14assert( atomic_inc()==1)
13assert( atomic_inc()==2) 15assert( atomic_inc()==2)
14 16
15local function FIFO() 17local function FIFO()
16 local my_channel= "FIFO"..atomic_inc() 18 local my_channel= "FIFO_"..atomic_inc()
17 19
18 return { 20 return {
19 -- Giving explicit 'nil' timeout allows numbers to be used as 'my_channel' 21 -- Giving explicit 'nil' timeout allows numbers to be used as 'my_channel'
20 -- 22 --
21 send = function(self, ...) 23 send = function(self, ...)
22 linda:send( nil, my_channel, ...) 24 fifo_linda:send( nil, my_channel, ...)
23 end, 25 end,
24 receive = function(self, timeout) 26 receive = function(self, timeout)
25 return linda:receive( timeout, my_channel) 27 return fifo_linda:receive( timeout, my_channel)
26 end 28 end,
29 channel = my_channel
27 } 30 }
28end 31end
29 32
@@ -36,11 +39,31 @@ A:send( 1,2,3,4,5)
36print "Sending to B.." 39print "Sending to B.."
37B:send( 'a','b','c') 40B:send( 'a','b','c')
38 41
42print "Dumping linda stats.. [1]" -- count everything
43for key,count in pairs(fifo_linda:count()) do
44 print("channel " .. key .. " contains " .. count .. " entries.")
45 -- print(i, key_count[1], key_count[2])
46end
47print "Dumping linda stats.. [2]" -- query count for known channels one at a time
48print("channel " .. A.channel .. " contains " .. fifo_linda:count(A.channel) .. " entries.")
49print("channel " .. B.channel .. " contains " .. fifo_linda:count(B.channel) .. " entries.")
50print "Dumping linda stats.. [3]" -- query counts for a predefined list of keys
51for key,count in pairs(fifo_linda:count(A.channel, B.channel)) do
52 print("channel " .. key .. " contains " .. count .. " entries.")
53 -- print(i, key_count[1], key_count[2])
54end
55
39print "Reading A.." 56print "Reading A.."
40print( A:receive( 1.0)) 57print( A:receive( 1.0))
58print( A:receive( 1.0))
59print( A:receive( 1.0))
60print( A:receive( 1.0))
61print( A:receive( 1.0))
41 62
42print "Reading B.." 63print "Reading B.."
43print( B:receive( 2.0)) 64print( B:receive( 2.0))
65print( B:receive( 2.0))
66print( B:receive( 2.0))
44 67
45-- Note: A and B can be passed between threads, or used as upvalues 68-- Note: A and B can be passed between threads, or used as upvalues
46-- by multiple threads (other parts will be copied but the 'linda' 69-- by multiple threads (other parts will be copied but the 'linda'