diff options
Diffstat (limited to 'unit_tests/scripts/lane/cooperative_shutdown.lua')
-rw-r--r-- | unit_tests/scripts/lane/cooperative_shutdown.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/unit_tests/scripts/lane/cooperative_shutdown.lua b/unit_tests/scripts/lane/cooperative_shutdown.lua index 756e33c..0a0943e 100644 --- a/unit_tests/scripts/lane/cooperative_shutdown.lua +++ b/unit_tests/scripts/lane/cooperative_shutdown.lua | |||
@@ -1,10 +1,10 @@ | |||
1 | local lanes = require "lanes" | 1 | local lanes = require "lanes".configure{on_state_create = require "fixture".on_state_create} |
2 | 2 | ||
3 | -- launch lanes that cooperate properly with cancellation request | 3 | -- launch lanes that cooperate properly with cancellation request |
4 | 4 | ||
5 | local lane1 = function() | 5 | local lane1 = function() |
6 | lane_threadname("lane1") | 6 | lane_threadname("lane1") |
7 | -- loop breaks on cancellation request | 7 | -- loop breaks on soft cancellation request |
8 | repeat | 8 | repeat |
9 | lanes.sleep(0) | 9 | lanes.sleep(0) |
10 | until cancel_test() | 10 | until cancel_test() |
@@ -23,7 +23,6 @@ end | |||
23 | local lane3 = function() | 23 | local lane3 = function() |
24 | lane_threadname("lane3") | 24 | lane_threadname("lane3") |
25 | -- this one cooperates too, because of the hook cancellation modes that Lanes will be using | 25 | -- this one cooperates too, because of the hook cancellation modes that Lanes will be using |
26 | -- but not with LuaJIT, because the function is compiled, and we don't call anyone, so no hook triggers | ||
27 | local fixture = require "fixture" | 26 | local fixture = require "fixture" |
28 | repeat until fixture.give_me_back(false) | 27 | repeat until fixture.give_me_back(false) |
29 | end | 28 | end |
@@ -43,7 +42,14 @@ local h2 = g2(linda) | |||
43 | 42 | ||
44 | local h3 = g3() | 43 | local h3 = g3() |
45 | 44 | ||
46 | -- wait until they are both started | 45 | lanes.sleep(0.1) |
47 | repeat until h1.status == "running" and h2.status == "waiting" and h3.status == "running" | 46 | |
47 | local is_running = function(lane_h) | ||
48 | local status = lane_h.status | ||
49 | return status == "running" or status == "waiting" | ||
50 | end | ||
51 | |||
52 | -- wait until they are all started | ||
53 | repeat until is_running(h1) and is_running(h2) and is_running(h3) | ||
48 | 54 | ||
49 | -- let the script terminate, Lanes should not crash at shutdown | 55 | -- let the script terminate, Lanes should not crash at shutdown |