summaryrefslogtreecommitdiff
path: root/test/fiber/test_scheduler.rb
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-06-14 17:56:53 +1200
committerGitHub <noreply@github.com>2021-06-14 17:56:53 +1200
commit050a89543952a2c9e7c9bc938f4fdb538f6c9278 (patch)
tree892fdfcf5188842ca6ae4e176a57284aa2a1e0b0 /test/fiber/test_scheduler.rb
parent626427c2e0f886ff8353c5faa8254699afd88ca8 (diff)
Wake up join list within thread EC context. (#4471)
* Wake up join list within thread EC context. * Consume items from join list so that they are not re-executed. If `rb_fiber_scheduler_unblock` raises an exception, it can result in a segfault if `rb_threadptr_join_list_wakeup` is not within a valid EC. This change moves `rb_threadptr_join_list_wakeup` into the thread's top level EC which initially caused an infinite loop because on exception will retry. We explicitly remove items from the thread's join list to avoid this situation. * Verify the required scheduler interface. * Test several scheduler hooks methods with broken `unblock` implementation.
Notes
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'test/fiber/test_scheduler.rb')
-rw-r--r--test/fiber/test_scheduler.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/fiber/test_scheduler.rb b/test/fiber/test_scheduler.rb
index eeb0d67ec5..f0f5b79f36 100644
--- a/test/fiber/test_scheduler.rb
+++ b/test/fiber/test_scheduler.rb
@@ -66,9 +66,23 @@ class TestFiberScheduler < Test::Unit::TestCase
RUBY
end
- def test_optional_close
+ def test_minimal_interface
+ scheduler = Object.new
+
+ def scheduler.block
+ end
+
+ def scheduler.unblock
+ end
+
+ def scheduler.io_wait
+ end
+
+ def scheduler.kernel_sleep
+ end
+
thread = Thread.new do
- Fiber.set_scheduler Object.new
+ Fiber.set_scheduler scheduler
end
thread.join