aboutsummaryrefslogtreecommitdiff
path: root/tests/track_lanes.lua
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-05-31 17:04:17 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-05-31 17:04:17 +0200
commitf7a38b5681ebf7429828fca9a9f7c109df853d54 (patch)
tree9c4e702071a6915719ca639790936b35ed1ed828 /tests/track_lanes.lua
parent95e5bf6461be6e227466911d5e3a683d149df725 (diff)
downloadlanes-f7a38b5681ebf7429828fca9a9f7c109df853d54.tar.gz
lanes-f7a38b5681ebf7429828fca9a9f7c109df853d54.tar.bz2
lanes-f7a38b5681ebf7429828fca9a9f7c109df853d54.zip
Some API changes
* lanes.timers() can return nil, cancel_error if interrupted * linda:receive() always return a k,v, where k is nil when v is "timeout" or cancel_error * lanes.sleep returns nil, "timeout" during normal operations
Diffstat (limited to '')
-rw-r--r--tests/track_lanes.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/track_lanes.lua b/tests/track_lanes.lua
index daaa94c..5ea9a4e 100644
--- a/tests/track_lanes.lua
+++ b/tests/track_lanes.lua
@@ -1,5 +1,9 @@
1local lanes = require "lanes" .configure{ with_timers = false, track_lanes = true} 1local lanes = require "lanes" .configure{ with_timers = false, track_lanes = true}
2local wait = lanes.sleep 2
3local SLEEP = function(...)
4 local k, v = lanes.sleep(...)
5 assert(k == nil and v == "timeout")
6end
3 7
4print "hello" 8print "hello"
5 9
@@ -43,7 +47,7 @@ g( "forever", 'indefinitely')
43g( "two_seconds", 2) 47g( "two_seconds", 2)
44 48
45-- give a bit of time to reach the linda waiting call 49-- give a bit of time to reach the linda waiting call
46wait( 0.1) 50SLEEP(0.1)
47 51
48-- list the known lanes (should be living lanes) 52-- list the known lanes (should be living lanes)
49local threads = track( "============= START", 2) 53local threads = track( "============= START", 2)
@@ -51,7 +55,7 @@ local threads = track( "============= START", 2)
51assert(threads[1].status == 'waiting' and threads[2].status == 'waiting') 55assert(threads[1].status == 'waiting' and threads[2].status == 'waiting')
52 56
53-- wait until "two_seconds has completed" 57-- wait until "two_seconds has completed"
54wait(2.1) 58SLEEP(2.1)
55 59
56local threads = track( "============= two_seconds dead", 2) 60local threads = track( "============= two_seconds dead", 2)
57-- two_seconds forever 61-- two_seconds forever
@@ -61,7 +65,7 @@ assert(threads[1].status == 'done' and threads[2].status == 'waiting')
61g( "two_seconds", 2) 65g( "two_seconds", 2)
62 66
63-- give a bit of time to reach the linda waiting call 67-- give a bit of time to reach the linda waiting call
64wait( 0.1) 68SLEEP( 0.1)
65 69
66-- list the known lanes 70-- list the known lanes
67-- unless garbage collector cleaned it, we should have 3 lanes 71-- unless garbage collector cleaned it, we should have 3 lanes