summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-10-01 13:44:23 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-10-01 16:56:05 +1300
commitdd2e95fb26b89ce060631af0fd372b5780a443dd (patch)
treef1c4f538f760038e3b34221e29d4db5642be2a0b
parent7f2902059031ffe0dad35c9832e4be33d57c5588 (diff)
Remove `Thread.scheduler` from public interface.
It's implementation is equivalent to: Thread.current.scheduler unless Thread.current.blocking?
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3610
-rw-r--r--test/fiber/test_mutex.rb13
-rw-r--r--thread.c2
2 files changed, 7 insertions, 8 deletions
diff --git a/test/fiber/test_mutex.rb b/test/fiber/test_mutex.rb
index 258f5358a6..c38d45b189 100644
--- a/test/fiber/test_mutex.rb
+++ b/test/fiber/test_mutex.rb
@@ -11,10 +11,10 @@ class TestFiberMutex < Test::Unit::TestCase
Thread.current.scheduler = scheduler
Fiber.schedule do
- assert_equal Thread.scheduler, scheduler
+ refute Thread.current.blocking?
mutex.synchronize do
- assert Thread.scheduler
+ refute Thread.current.blocking?
end
end
end
@@ -83,9 +83,9 @@ class TestFiberMutex < Test::Unit::TestCase
f = Fiber.schedule do
assert_raise_with_message(RuntimeError, "bye") do
- assert_same scheduler, Thread.scheduler
mutex.lock
end
+
ran = true
end
@@ -196,8 +196,9 @@ class TestFiberMutex < Test::Unit::TestCase
end
def test_mutex_deadlock
- err = /No live threads left. Deadlock\?/
- assert_in_out_err %W[-I#{__dir__} -], <<-RUBY, ['in synchronize'], err, success: false
+ error_pattern = /No live threads left. Deadlock\?/
+
+ assert_in_out_err %W[-I#{__dir__} -], <<-RUBY, ['in synchronize'], error_pattern, success: false
require 'scheduler'
mutex = Mutex.new
@@ -206,8 +207,6 @@ class TestFiberMutex < Test::Unit::TestCase
Thread.current.scheduler = scheduler
Fiber.schedule do
- raise unless Thread.scheduler == scheduler
-
mutex.synchronize do
puts 'in synchronize'
Fiber.yield
diff --git a/thread.c b/thread.c
index 510d8a028b..3aca71dd6c 100644
--- a/thread.c
+++ b/thread.c
@@ -5519,7 +5519,7 @@ Init_Thread(void)
rb_define_method(rb_cThread, "backtrace", rb_thread_backtrace_m, -1);
rb_define_method(rb_cThread, "backtrace_locations", rb_thread_backtrace_locations_m, -1);
- rb_define_singleton_method(rb_cThread, "scheduler", rb_thread_scheduler, 0);
+ // rb_define_singleton_method(rb_cThread, "scheduler", rb_thread_scheduler, 0);
rb_define_method(rb_cThread, "scheduler", rb_thread_scheduler_get, 0);
rb_define_method(rb_cThread, "scheduler=", rb_thread_scheduler_set, 1);