From f37a7c2334fdfb8f30d0b76ecf25aff484adec28 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Thu, 4 Jul 2024 09:12:32 +0200 Subject: Fix finalizers in coroutine lanes --- tests/cancel.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/cancel.lua b/tests/cancel.lua index 9ee986c..8dfccd2 100644 --- a/tests/cancel.lua +++ b/tests/cancel.lua @@ -26,6 +26,9 @@ local linda = lanes.linda() -- a numeric value to read linda:set( "val", 33.0) +-- so that we can easily swap between lanes.gen and lanes.coro, to try stuff +local generator = lanes.coro + -- ################################################################################################## if not next(which_tests) or which_tests.genlock then @@ -149,7 +152,7 @@ end if not next(which_tests) or which_tests.linda then remaining_tests.linda = nil print "\n\n####################################################################\nbegin linda cancel test\n" - h = lanes.gen( "*", laneBody)( "receive", nil) -- start an infinite wait on the linda + h = generator( "*", laneBody)( "receive", nil) -- start an infinite wait on the linda print "wait 1s" SLEEP(1) @@ -170,7 +173,7 @@ end if not next(which_tests) or which_tests.soft then remaining_tests.soft = nil print "\n\n####################################################################\nbegin soft cancel test\n" - h = lanes.gen( "*", protectedBody)( "receive") -- start an infinite wait on the linda + h = generator( "*", protectedBody)( "receive") -- start an infinite wait on the linda print "wait 1s" SLEEP(1) @@ -194,7 +197,7 @@ end if not next(which_tests) or which_tests.hook then remaining_tests.hook = nil print "\n\n####################################################################\nbegin hook cancel test\n" - h = lanes.gen( "*", protectedBody)( "get", 300000) + h = generator( "*", protectedBody)( "get", 300000) print "wait 2s" SLEEP(2) @@ -230,7 +233,7 @@ end if not next(which_tests) or which_tests.hard_unprotected then remaining_tests.hard_unprotected = nil print "\n\n####################################################################\nbegin hard cancel test with unprotected lane body\n" - h = lanes.gen( "*", laneBody)( "receive", nil) + h = generator( "*", laneBody)( "receive", nil) -- wait 2s before cancelling the lane print "wait 2s" -- cgit v1.2.3-55-g6feb