summaryrefslogtreecommitdiff
path: root/test/fiber
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-06-28 23:01:53 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-06-29 11:41:10 +0900
commit9eae8cdefba61e9e51feb30a4b98525593169666 (patch)
treeb54d8502f7e7733e48c798e517f7676bf0395a51 /test/fiber
parent983c9ad3f197ab8612c08ea894765b43ed089749 (diff)
Prefer qualified names under Thread
Diffstat (limited to 'test/fiber')
-rw-r--r--test/fiber/scheduler.rb10
-rw-r--r--test/fiber/test_mutex.rb18
2 files changed, 15 insertions, 13 deletions
diff --git a/test/fiber/scheduler.rb b/test/fiber/scheduler.rb
index c844200935..af64e4ebb6 100644
--- a/test/fiber/scheduler.rb
+++ b/test/fiber/scheduler.rb
@@ -21,7 +21,7 @@ class Scheduler
@closed = false
- @lock = Mutex.new
+ @lock = Thread::Mutex.new
@blocking = 0
@ready = []
@@ -170,7 +170,7 @@ class Scheduler
Fiber.yield
end
- # Used for Kernel#sleep and Mutex#sleep
+ # Used for Kernel#sleep and Thread::Mutex#sleep
def kernel_sleep(duration = nil)
# $stderr.puts [__method__, duration, Fiber.current].inspect
@@ -179,7 +179,8 @@ class Scheduler
return true
end
- # Used when blocking on synchronization (Mutex#lock, Queue#pop, SizedQueue#push, ...)
+ # Used when blocking on synchronization (Thread::Mutex#lock,
+ # Thread::Queue#pop, Thread::SizedQueue#push, ...)
def block(blocker, timeout = nil)
# $stderr.puts [__method__, blocker, timeout].inspect
@@ -201,7 +202,8 @@ class Scheduler
end
end
- # Used when synchronization wakes up a previously-blocked fiber (Mutex#unlock, Queue#push, ...).
+ # Used when synchronization wakes up a previously-blocked fiber
+ # (Thread::Mutex#unlock, Thread::Queue#push, ...).
# This might be called from another thread.
def unblock(blocker, fiber)
# $stderr.puts [__method__, blocker, fiber].inspect
diff --git a/test/fiber/test_mutex.rb b/test/fiber/test_mutex.rb
index 0842427760..b0655f06a5 100644
--- a/test/fiber/test_mutex.rb
+++ b/test/fiber/test_mutex.rb
@@ -4,7 +4,7 @@ require_relative 'scheduler'
class TestFiberMutex < Test::Unit::TestCase
def test_mutex_synchronize
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
thread = Thread.new do
scheduler = Scheduler.new
@@ -23,7 +23,7 @@ class TestFiberMutex < Test::Unit::TestCase
end
def test_mutex_interleaved_locking
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
thread = Thread.new do
scheduler = Scheduler.new
@@ -48,7 +48,7 @@ class TestFiberMutex < Test::Unit::TestCase
end
def test_mutex_thread
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
mutex.lock
thread = Thread.new do
@@ -71,7 +71,7 @@ class TestFiberMutex < Test::Unit::TestCase
end
def test_mutex_fiber_raise
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
ran = false
main = Thread.new do
@@ -103,8 +103,8 @@ class TestFiberMutex < Test::Unit::TestCase
end
def test_condition_variable
- mutex = Mutex.new
- condition = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condition = Thread::ConditionVariable.new
signalled = 0
@@ -138,7 +138,7 @@ class TestFiberMutex < Test::Unit::TestCase
end
def test_queue
- queue = Queue.new
+ queue = Thread::Queue.new
processed = 0
thread = Thread.new do
@@ -169,7 +169,7 @@ class TestFiberMutex < Test::Unit::TestCase
end
def test_queue_pop_waits
- queue = Queue.new
+ queue = Thread::Queue.new
running = false
thread = Thread.new do
@@ -198,7 +198,7 @@ class TestFiberMutex < Test::Unit::TestCase
assert_in_out_err %W[-I#{__dir__} -], <<-RUBY, ['in synchronize'], error_pattern, success: false
require 'scheduler'
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
thread = Thread.new do
scheduler = Scheduler.new