summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fiber/scheduler.rb10
-rw-r--r--test/fiber/test_mutex.rb18
-rw-r--r--test/monitor/test_monitor.rb22
-rw-r--r--test/ruby/test_bignum.rb2
-rw-r--r--test/ruby/test_dir.rb2
-rw-r--r--test/ruby/test_exception.rb2
-rw-r--r--test/ruby/test_io.rb2
-rw-r--r--test/ruby/test_process.rb2
-rw-r--r--test/ruby/test_settracefunc.rb8
-rw-r--r--test/ruby/test_thread.rb14
-rw-r--r--test/ruby/test_thread_cv.rb52
-rw-r--r--test/ruby/test_thread_queue.rb80
-rw-r--r--test/test_pstore.rb4
-rw-r--r--test/yaml/test_store.rb4
14 files changed, 112 insertions, 110 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
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb
index 0f17d58f71..3eceee7b2e 100644
--- a/test/monitor/test_monitor.rb
+++ b/test/monitor/test_monitor.rb
@@ -19,7 +19,7 @@ class TestMonitor < Test::Unit::TestCase
def test_enter
ary = []
- queue = Queue.new
+ queue = Thread::Queue.new
th = Thread.start {
queue.pop
@monitor.enter
@@ -83,7 +83,7 @@ class TestMonitor < Test::Unit::TestCase
def test_synchronize
ary = []
- queue = Queue.new
+ queue = Thread::Queue.new
th = Thread.start {
queue.pop
@monitor.synchronize do
@@ -108,7 +108,7 @@ class TestMonitor < Test::Unit::TestCase
def test_killed_thread_in_synchronize
ary = []
- queue = Queue.new
+ queue = Thread::Queue.new
t1 = Thread.start {
queue.pop
@monitor.synchronize {
@@ -136,8 +136,8 @@ class TestMonitor < Test::Unit::TestCase
end
def test_try_enter
- queue1 = Queue.new
- queue2 = Queue.new
+ queue1 = Thread::Queue.new
+ queue2 = Thread::Queue.new
th = Thread.start {
queue1.deq
@monitor.enter
@@ -176,8 +176,8 @@ class TestMonitor < Test::Unit::TestCase
end
def test_mon_locked_and_owned
- queue1 = Queue.new
- queue2 = Queue.new
+ queue1 = Thread::Queue.new
+ queue2 = Thread::Queue.new
th = Thread.start {
@monitor.enter
queue1.enq(nil)
@@ -210,7 +210,7 @@ class TestMonitor < Test::Unit::TestCase
cond = @monitor.new_cond
a = "foo"
- queue1 = Queue.new
+ queue1 = Thread::Queue.new
th = Thread.start do
queue1.deq
@monitor.synchronize do
@@ -262,7 +262,7 @@ class TestMonitor < Test::Unit::TestCase
def test_timedwait
cond = @monitor.new_cond
b = "foo"
- queue2 = Queue.new
+ queue2 = Thread::Queue.new
th = Thread.start do
queue2.deq
@monitor.synchronize do
@@ -282,7 +282,7 @@ class TestMonitor < Test::Unit::TestCase
assert_join_threads([th, th2])
c = "foo"
- queue3 = Queue.new
+ queue3 = Thread::Queue.new
th = Thread.start do
queue3.deq
@monitor.synchronize do
@@ -312,7 +312,7 @@ class TestMonitor < Test::Unit::TestCase
# end
# end
# }
-# queue3 = Queue.new
+# queue3 = Thread::Queue.new
# Thread.start do
# queue3.pop
# @monitor.synchronize do
diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb
index 68c8461951..3ffe7114b5 100644
--- a/test/ruby/test_bignum.rb
+++ b/test/ruby/test_bignum.rb
@@ -632,7 +632,7 @@ class TestBignum < Test::Unit::TestCase
time = Time.now
end_flag = false
num = (65536 ** 65536)
- q = Queue.new
+ q = Thread::Queue.new
thread = Thread.new do
assert_raise(RuntimeError) {
q << true
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index bb268f2ab3..71bff5f5c3 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -131,7 +131,7 @@ class TestDir < Test::Unit::TestCase
def test_chdir_conflict
pwd = Dir.pwd
- q = Queue.new
+ q = Thread::Queue.new
t = Thread.new do
q.pop
Dir.chdir(pwd) rescue $!
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 8c4e6889ab..62da13d1b9 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -814,7 +814,7 @@ end.join
bug12741 = '[ruby-core:77222] [Bug #12741]'
x = Thread.current
- q = Queue.new
+ q = Thread::Queue.new
y = Thread.start do
q.pop
begin
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 7acedb60e2..f7240c4cf6 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -3736,7 +3736,7 @@ __END__
begin;
bug13158 = '[ruby-core:79262] [Bug #13158]'
closed = nil
- q = Queue.new
+ q = Thread::Queue.new
IO.pipe do |r, w|
thread = Thread.new do
begin
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 0493544139..80d2eefca9 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -2433,7 +2433,7 @@ EOS
rescue SystemCallError
w.syswrite("exec failed\n")
end
- q = Queue.new
+ q = Thread::Queue.new
th1 = Thread.new { i = 0; i += 1 while q.empty?; i }
th2 = Thread.new { j = 0; j += 1 while q.empty? && Thread.pass.nil?; j }
sleep 0.5
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index c8ec81c72a..dafe58d70c 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -1984,7 +1984,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
def test_thread_add_trace_func
events = []
base_line = __LINE__
- q = Queue.new
+ q = Thread::Queue.new
t = Thread.new{
Thread.current.add_trace_func proc{|ev, file, line, *args|
events << [ev, line]
@@ -2010,7 +2010,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
# other thread
events = []
- m2t_q = Queue.new
+ m2t_q = Thread::Queue.new
t = Thread.new{
Thread.current.abort_on_exception = true
@@ -2320,8 +2320,8 @@ class TestSetTraceFunc < Test::Unit::TestCase
events << Thread.current
end
- q1 = Queue.new
- q2 = Queue.new
+ q1 = Thread::Queue.new
+ q2 = Thread::Queue.new
th = Thread.new{
q1 << :ok; q2.pop
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index dbd0328e28..a75d42b962 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -496,7 +496,7 @@ class TestThread < Test::Unit::TestCase
end
assert_in_out_err([], <<-INPUT, %w(false :sig), [], :signal=>:INT, timeout: 1, timeout_error: nil)
p Thread.ignore_deadlock
- q = Queue.new
+ q = Thread::Queue.new
trap(:INT){q.push :sig}
Thread.ignore_deadlock = true
p q.pop
@@ -731,8 +731,8 @@ class TestThread < Test::Unit::TestCase
def make_handle_interrupt_test_thread1 flag
r = []
- ready_q = Queue.new
- done_q = Queue.new
+ ready_q = Thread::Queue.new
+ done_q = Thread::Queue.new
th = Thread.new{
begin
Thread.handle_interrupt(RuntimeError => flag){
@@ -809,7 +809,7 @@ class TestThread < Test::Unit::TestCase
def test_handle_interrupt_blocking
r = nil
- q = Queue.new
+ q = Thread::Queue.new
e = Class.new(Exception)
th_s = Thread.current
th = Thread.start {
@@ -833,7 +833,7 @@ class TestThread < Test::Unit::TestCase
def test_handle_interrupt_and_io
assert_in_out_err([], <<-INPUT, %w(ok), [])
th_waiting = true
- q = Queue.new
+ q = Thread::Queue.new
t = Thread.new {
Thread.current.report_on_exception = false
@@ -1235,7 +1235,7 @@ q.pop
end if Process.respond_to?(:fork)
def test_fork_while_locked
- m = Mutex.new
+ m = Thread::Mutex.new
thrs = []
3.times do |i|
thrs << Thread.new { m.synchronize { Process.waitpid2(fork{})[1] } }
@@ -1268,7 +1268,7 @@ q.pop
def test_fork_while_mutex_locked_by_forker
skip 'needs fork' unless Process.respond_to?(:fork)
- m = Mutex.new
+ m = Thread::Mutex.new
m.synchronize do
pid = fork do
exit!(2) unless m.locked?
diff --git a/test/ruby/test_thread_cv.rb b/test/ruby/test_thread_cv.rb
index 38bcc3b8fa..5f19b85bc0 100644
--- a/test/ruby/test_thread_cv.rb
+++ b/test/ruby/test_thread_cv.rb
@@ -13,8 +13,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
end
def test_condvar_signal_and_wait
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
result = []
mutex.synchronize do
t = Thread.new do
@@ -35,8 +35,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
def test_condvar_wait_exception_handling
# Calling wait in the only thread running should raise a ThreadError of
# 'stopping only thread'
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
locked = false
thread = Thread.new do
@@ -61,8 +61,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
def test_condvar_wait_and_broadcast
nr_threads = 3
threads = Array.new
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
result = []
nr_threads.times do |i|
@@ -91,8 +91,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
def test_condvar_wait_deadlock
assert_in_out_err([], <<-INPUT, /\Afatal\nNo live threads left\. Deadlock/, [])
- mutex = Mutex.new
- cv = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ cv = Thread::ConditionVariable.new
klass = nil
mesg = nil
@@ -112,8 +112,8 @@ INPUT
def test_condvar_wait_deadlock_2
nr_threads = 3
threads = Array.new
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
nr_threads.times do |i|
if (i != 0)
@@ -136,8 +136,8 @@ INPUT
end
def test_condvar_timed_wait
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
timeout = 0.3
locked = false
@@ -157,15 +157,15 @@ INPUT
end
def test_condvar_nolock
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
assert_raise(ThreadError) {condvar.wait(mutex)}
end
def test_condvar_nolock_2
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
Thread.new do
assert_raise(ThreadError) {condvar.wait(mutex)}
@@ -173,8 +173,8 @@ INPUT
end
def test_condvar_nolock_3
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
Thread.new do
assert_raise(ThreadError) {condvar.wait(mutex, 0.1)}
@@ -182,22 +182,22 @@ INPUT
end
def test_condvar_empty_signal
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
assert_nothing_raised(Exception) { mutex.synchronize {condvar.signal} }
end
def test_condvar_empty_broadcast
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} }
end
def test_dup
bug9440 = '[ruby-core:59961] [Bug #9440]'
- condvar = ConditionVariable.new
+ condvar = Thread::ConditionVariable.new
assert_raise(NoMethodError, bug9440) do
condvar.dup
end
@@ -207,7 +207,7 @@ INPUT
def test_dump
bug9674 = '[ruby-core:61677] [Bug #9674]'
- condvar = ConditionVariable.new
+ condvar = Thread::ConditionVariable.new
assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do
Marshal.dump(condvar)
end
@@ -219,8 +219,8 @@ INPUT
end
def test_condvar_fork
- mutex = Mutex.new
- condvar = ConditionVariable.new
+ mutex = Thread::Mutex.new
+ condvar = Thread::ConditionVariable.new
thrs = (1..10).map do
Thread.new { mutex.synchronize { condvar.wait(mutex) } }
end
diff --git a/test/ruby/test_thread_queue.rb b/test/ruby/test_thread_queue.rb
index 6185abff9f..3fa0eae2c1 100644
--- a/test/ruby/test_thread_queue.rb
+++ b/test/ruby/test_thread_queue.rb
@@ -66,7 +66,7 @@ class TestThreadQueue < Test::Unit::TestCase
[e, "Enumerable"],
[Struct.new(:to_a), "Array-like"],
) do |a, type|
- q = Queue.new(a.new([1,2,3]))
+ q = Thread::Queue.new(a.new([1,2,3]))
assert_equal(3, q.size, type)
assert_not_predicate(q, :empty?, type)
assert_equal(1, q.pop, type)
@@ -77,14 +77,14 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_sized_queue_initialize
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
assert_equal 1, q.max
- assert_raise(ArgumentError) { SizedQueue.new(0) }
- assert_raise(ArgumentError) { SizedQueue.new(-1) }
+ assert_raise(ArgumentError) { Thread::SizedQueue.new(0) }
+ assert_raise(ArgumentError) { Thread::SizedQueue.new(-1) }
end
def test_sized_queue_assign_max
- q = SizedQueue.new(2)
+ q = Thread::SizedQueue.new(2)
assert_equal(2, q.max)
q.max = 1
assert_equal(1, q.max)
@@ -104,7 +104,7 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_queue_pop_interrupt
- q = Queue.new
+ q = Thread::Queue.new
t1 = Thread.new { q.pop }
sleep 0.01 until t1.stop?
t1.kill.join
@@ -112,14 +112,14 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_queue_pop_non_block
- q = Queue.new
+ q = Thread::Queue.new
assert_raise_with_message(ThreadError, /empty/) do
q.pop(true)
end
end
def test_sized_queue_pop_interrupt
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
t1 = Thread.new { q.pop }
sleep 0.01 until t1.stop?
t1.kill.join
@@ -127,14 +127,14 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_sized_queue_pop_non_block
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
assert_raise_with_message(ThreadError, /empty/) do
q.pop(true)
end
end
def test_sized_queue_push_interrupt
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
q.push(1)
assert_raise_with_message(ThreadError, /full/) do
q.push(2, true)
@@ -142,7 +142,7 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_sized_queue_push_non_block
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
q.push(1)
t1 = Thread.new { q.push(2) }
sleep 0.01 until t1.stop?
@@ -159,7 +159,7 @@ class TestThreadQueue < Test::Unit::TestCase
assert_normal_exit(<<-"_eom", bug5343, **{:timeout => timeout, :chdir=>d})
#{total_count}.times do |i|
open("test_thr_kill_count", "w") {|f| f.puts i }
- queue = Queue.new
+ queue = Thread::Queue.new
r, w = IO.pipe
th = Thread.start {
queue.push(nil)
@@ -178,20 +178,20 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_queue_push_return_value
- q = Queue.new
+ q = Thread::Queue.new
retval = q.push(1)
assert_same q, retval
end
def test_queue_clear_return_value
- q = Queue.new
+ q = Thread::Queue.new
retval = q.clear
assert_same q, retval
end
def test_sized_queue_clear
- # Fill queue, then test that SizedQueue#clear wakes up all waiting threads
- sq = SizedQueue.new(2)
+ # Fill queue, then test that Thread::SizedQueue#clear wakes up all waiting threads
+ sq = Thread::SizedQueue.new(2)
2.times { sq << 1 }
t1 = Thread.new do
@@ -212,19 +212,19 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_sized_queue_push_return_value
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
retval = q.push(1)
assert_same q, retval
end
def test_sized_queue_clear_return_value
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
retval = q.clear
assert_same q, retval
end
def test_sized_queue_throttle
- q = SizedQueue.new(1)
+ q = Thread::SizedQueue.new(1)
i = 0
consumer = Thread.new do
while q.pop
@@ -247,7 +247,7 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_queue_thread_raise
- q = Queue.new
+ q = Thread::Queue.new
th1 = Thread.new do
begin
q.pop
@@ -277,7 +277,7 @@ class TestThreadQueue < Test::Unit::TestCase
def test_dup
bug9440 = '[ruby-core:59961] [Bug #9440]'
- q = Queue.new
+ q = Thread::Queue.new
assert_raise(NoMethodError, bug9440) do
q.dup
end
@@ -287,12 +287,12 @@ class TestThreadQueue < Test::Unit::TestCase
def test_dump
bug9674 = '[ruby-core:61677] [Bug #9674]'
- q = Queue.new
+ q = Thread::Queue.new
assert_raise_with_message(TypeError, /#{Queue}/, bug9674) do
Marshal.dump(q)
end
- sq = SizedQueue.new(1)
+ sq = Thread::SizedQueue.new(1)
assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do
Marshal.dump(sq)
end
@@ -304,7 +304,7 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_close
- [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
+ [->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate|
q = qcreate.call
assert_equal false, q.closed?
q << :something
@@ -343,15 +343,15 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_queue_close_wakeup
- close_wakeup(15, 18){Queue.new}
+ close_wakeup(15, 18){Thread::Queue.new}
end
def test_size_queue_close_wakeup
- close_wakeup(5, 8){SizedQueue.new 9}
+ close_wakeup(5, 8){Thread::SizedQueue.new 9}
end
def test_sized_queue_one_closed_interrupt
- q = SizedQueue.new 1
+ q = Thread::SizedQueue.new 1
q << :one
t1 = Thread.new {
Thread.current.report_on_exception = false
@@ -368,7 +368,7 @@ class TestThreadQueue < Test::Unit::TestCase
# make sure that shutdown state is handled properly by empty? for the non-blocking case
def test_empty_non_blocking
- q = SizedQueue.new 3
+ q = Thread::SizedQueue.new 3
3.times{|i| q << i}
# these all block cos the queue is full
@@ -394,13 +394,13 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_sized_queue_closed_push_non_blocking
- q = SizedQueue.new 7
+ q = Thread::SizedQueue.new 7
q.close
assert_raise_with_message(ClosedQueueError, /queue closed/){q.push(non_block=true)}
end
def test_blocked_pushers
- q = SizedQueue.new 3
+ q = Thread::SizedQueue.new 3
prod_threads = 6.times.map do |i|
thr = Thread.new{
Thread.current.report_on_exception = false
@@ -446,9 +446,9 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_deny_pushers
- [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
+ [->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate|
q = qcreate[]
- synq = Queue.new
+ synq = Thread::Queue.new
prod_threads = 20.times.map do |i|
Thread.new {
synq.pop
@@ -466,7 +466,7 @@ class TestThreadQueue < Test::Unit::TestCase
# size should account for waiting pushers during shutdown
def sized_queue_size_close
- q = SizedQueue.new 4
+ q = Thread::SizedQueue.new 4
4.times{|i| q << i}
Thread.new{ q << 5 }
Thread.new{ q << 6 }
@@ -478,7 +478,7 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_blocked_pushers_empty
- q = SizedQueue.new 3
+ q = Thread::SizedQueue.new 3
prod_threads = 6.times.map do |i|
Thread.new{
Thread.current.report_on_exception = false
@@ -510,14 +510,14 @@ class TestThreadQueue < Test::Unit::TestCase
# test thread wakeup on one-element SizedQueue with close
def test_one_element_sized_queue
- q = SizedQueue.new 1
+ q = Thread::SizedQueue.new 1
t = Thread.new{ q.pop }
q.close
assert_nil t.value
end
def test_close_twice
- [->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
+ [->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate|
q = qcreate[]
q.close
assert_nothing_raised(ClosedQueueError){q.close}
@@ -525,7 +525,7 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_queue_close_multi_multi
- q = SizedQueue.new rand(800..1200)
+ q = Thread::SizedQueue.new rand(800..1200)
count_items = rand(3000..5000)
count_producers = rand(10..20)
@@ -587,7 +587,7 @@ class TestThreadQueue < Test::Unit::TestCase
end
assert_in_out_err([], <<-INPUT, %w(INT INT exit), [])
- q = Queue.new
+ q = Thread::Queue.new
trap(:INT){
q.push 'INT'
}
@@ -604,8 +604,8 @@ class TestThreadQueue < Test::Unit::TestCase
end
def test_fork_while_queue_waiting
- q = Queue.new
- sq = SizedQueue.new(1)
+ q = Thread::Queue.new
+ sq = Thread::SizedQueue.new(1)
thq = Thread.new { q.pop }
thsq = Thread.new { sq.pop }
Thread.pass until thq.stop? && thsq.stop?
diff --git a/test/test_pstore.rb b/test/test_pstore.rb
index 52b74f3775..fe5f8711a4 100644
--- a/test/test_pstore.rb
+++ b/test/test_pstore.rb
@@ -75,7 +75,7 @@ class PStoreTest < Test::Unit::TestCase
end
def test_thread_safe
- q1 = Queue.new
+ q1 = Thread::Queue.new
assert_raise(PStore::Error) do
th = Thread.new do
@pstore.transaction do
@@ -92,7 +92,7 @@ class PStoreTest < Test::Unit::TestCase
th.join
end
end
- q2 = Queue.new
+ q2 = Thread::Queue.new
begin
pstore = PStore.new(second_file, true)
cur = Thread.current
diff --git a/test/yaml/test_store.rb b/test/yaml/test_store.rb
index 9112c569a3..ef8d3229c1 100644
--- a/test/yaml/test_store.rb
+++ b/test/yaml/test_store.rb
@@ -75,7 +75,7 @@ class YAMLStoreTest < Test::Unit::TestCase
end
def test_thread_safe
- q1 = Queue.new
+ q1 = Thread::Queue.new
assert_raise(PStore::Error) do
th = Thread.new do
@yaml_store.transaction do
@@ -92,7 +92,7 @@ class YAMLStoreTest < Test::Unit::TestCase
th.join
end
end
- q2 = Queue.new
+ q2 = Thread::Queue.new
begin
yaml_store = YAML::Store.new(second_file, true)
cur = Thread.current