diff --git a/test/box/fiber.result b/test/box/fiber.result index 9b94d2d1986370a58545df45fe91e1e3b13f2208..e214b8d35665ad60b6df7c9f7eb4c1fe32a70929 100644 --- a/test/box/fiber.result +++ b/test/box/fiber.result @@ -610,11 +610,8 @@ test_run:cmd("setopt delimiter ';'") --- - true ... -function testfun(ch) - while fiber.self().storage.key == nil do - print('wait') - fiber.sleep(0) - end +function testfun(mgmt, ch) + mgmt:get() ch:put(fiber.self().storage.key) end; --- @@ -623,15 +620,22 @@ test_run:cmd("setopt delimiter ''"); --- - true ... -ch = fiber.channel(1) +mgmt = fiber.channel() --- ... -f = fiber.create(testfun, ch) +ch = fiber.channel() +--- +... +f = fiber.create(testfun, mgmt, ch) --- ... f.storage.key = 'some value' --- ... +mgmt:put("wakeup plz") +--- +- true +... ch:get() --- - some value @@ -639,9 +643,15 @@ ch:get() ch:close() --- ... +mgmt:close() +--- +... ch = nil --- ... +mgmt = nil +--- +... fiber.self().storage.key -- our local storage is not affected by f --- - 48 diff --git a/test/box/fiber.test.lua b/test/box/fiber.test.lua index b321fdb5b28cb3cc62a5e9c94d2ec967b42742d9..df8fc8f7ee79cbc3f185fc08af73a377c820f1a6 100644 --- a/test/box/fiber.test.lua +++ b/test/box/fiber.test.lua @@ -223,20 +223,21 @@ fiber.self().storage.key = 48 fiber.self().storage.key test_run:cmd("setopt delimiter ';'") -function testfun(ch) - while fiber.self().storage.key == nil do - print('wait') - fiber.sleep(0) - end +function testfun(mgmt, ch) + mgmt:get() ch:put(fiber.self().storage.key) end; test_run:cmd("setopt delimiter ''"); -ch = fiber.channel(1) -f = fiber.create(testfun, ch) +mgmt = fiber.channel() +ch = fiber.channel() +f = fiber.create(testfun, mgmt, ch) f.storage.key = 'some value' +mgmt:put("wakeup plz") ch:get() ch:close() +mgmt:close() ch = nil +mgmt = nil fiber.self().storage.key -- our local storage is not affected by f -- attempt to access local storage of dead fiber raises error pcall(function(f) return f.storage end, f)