diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-31 17:04:17 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-31 17:04:17 +0200 |
commit | f7a38b5681ebf7429828fca9a9f7c109df853d54 (patch) | |
tree | 9c4e702071a6915719ca639790936b35ed1ed828 /tests/track_lanes.lua | |
parent | 95e5bf6461be6e227466911d5e3a683d149df725 (diff) | |
download | lanes-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.lua | 12 |
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 @@ | |||
1 | local lanes = require "lanes" .configure{ with_timers = false, track_lanes = true} | 1 | local lanes = require "lanes" .configure{ with_timers = false, track_lanes = true} |
2 | local wait = lanes.sleep | 2 | |
3 | local SLEEP = function(...) | ||
4 | local k, v = lanes.sleep(...) | ||
5 | assert(k == nil and v == "timeout") | ||
6 | end | ||
3 | 7 | ||
4 | print "hello" | 8 | print "hello" |
5 | 9 | ||
@@ -43,7 +47,7 @@ g( "forever", 'indefinitely') | |||
43 | g( "two_seconds", 2) | 47 | g( "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 |
46 | wait( 0.1) | 50 | SLEEP(0.1) |
47 | 51 | ||
48 | -- list the known lanes (should be living lanes) | 52 | -- list the known lanes (should be living lanes) |
49 | local threads = track( "============= START", 2) | 53 | local threads = track( "============= START", 2) |
@@ -51,7 +55,7 @@ local threads = track( "============= START", 2) | |||
51 | assert(threads[1].status == 'waiting' and threads[2].status == 'waiting') | 55 | assert(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" |
54 | wait(2.1) | 58 | SLEEP(2.1) |
55 | 59 | ||
56 | local threads = track( "============= two_seconds dead", 2) | 60 | local 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') | |||
61 | g( "two_seconds", 2) | 65 | g( "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 |
64 | wait( 0.1) | 68 | SLEEP( 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 |