diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-01-14 17:47:41 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2025-01-14 17:47:41 -0800 |
| commit | f19831a15d680fd995ceaecad1157282be7182dc (patch) | |
| tree | 8b52b6fa8295326a93dafb041b5043cf6ecd6bad /test | |
| parent | 1ec258ab7002210670171f3f2f0c4b39657e24a4 (diff) | |
merge revision(s) a8c2d5e7bee5fad0965baeb58d312ddc5932ec26: [Backport #20907]
Ensure fiber scheduler re-acquires mutex when interrupted from sleep. (#12158)
[Bug #20907]
Diffstat (limited to 'test')
| -rw-r--r-- | test/fiber/test_scheduler.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/fiber/test_scheduler.rb b/test/fiber/test_scheduler.rb index 34effad816..62424fc489 100644 --- a/test/fiber/test_scheduler.rb +++ b/test/fiber/test_scheduler.rb @@ -182,4 +182,32 @@ class TestFiberScheduler < Test::Unit::TestCase thread.join signaller.join end + + def test_condition_variable + condition_variable = ::Thread::ConditionVariable.new + mutex = ::Thread::Mutex.new + + error = nil + + thread = Thread.new do + Thread.current.report_on_exception = false + + scheduler = Scheduler.new + Fiber.set_scheduler scheduler + + fiber = Fiber.schedule do + begin + mutex.synchronize do + condition_variable.wait(mutex) + end + rescue => error + end + end + + fiber.raise(RuntimeError) + end + + thread.join + assert_kind_of RuntimeError, error + end end |
