Prefer qualified names under Thread
This commit is contained in:
parent
983c9ad3f1
commit
9eae8cdefb
@ -1,9 +1,9 @@
|
|||||||
# two threads, two mutex, two condvar ping-pong
|
# two threads, two mutex, two condvar ping-pong
|
||||||
require 'thread'
|
require 'thread'
|
||||||
m1 = Mutex.new
|
m1 = Thread::Mutex.new
|
||||||
m2 = Mutex.new
|
m2 = Thread::Mutex.new
|
||||||
cv1 = ConditionVariable.new
|
cv1 = Thread::ConditionVariable.new
|
||||||
cv2 = ConditionVariable.new
|
cv2 = Thread::ConditionVariable.new
|
||||||
max = 100000
|
max = 100000
|
||||||
i = 0
|
i = 0
|
||||||
wait = nil
|
wait = nil
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
# many threads, one mutex, many condvars
|
# many threads, one mutex, many condvars
|
||||||
require 'thread'
|
require 'thread'
|
||||||
m = Mutex.new
|
m = Thread::Mutex.new
|
||||||
cv1 = ConditionVariable.new
|
cv1 = Thread::ConditionVariable.new
|
||||||
cv2 = ConditionVariable.new
|
cv2 = Thread::ConditionVariable.new
|
||||||
max = 1000
|
max = 1000
|
||||||
n = 100
|
n = 100
|
||||||
waiting = 0
|
waiting = 0
|
||||||
scvs = []
|
scvs = []
|
||||||
waiters = n.times.map do |i|
|
waiters = n.times.map do |i|
|
||||||
start_cv = ConditionVariable.new
|
start_cv = Thread::ConditionVariable.new
|
||||||
scvs << start_cv
|
scvs << start_cv
|
||||||
start_mtx = Mutex.new
|
start_mtx = Thread::Mutex.new
|
||||||
start_mtx.synchronize do
|
start_mtx.synchronize do
|
||||||
th = Thread.new(start_mtx, start_cv) do |sm, scv|
|
th = Thread.new(start_mtx, start_cv) do |sm, scv|
|
||||||
m.synchronize do
|
m.synchronize do
|
||||||
|
@ -384,7 +384,7 @@ tests = [
|
|||||||
[ 'opt_empty_p', %q{ ''.empty? }, ],
|
[ 'opt_empty_p', %q{ ''.empty? }, ],
|
||||||
[ 'opt_empty_p', %q{ [].empty? }, ],
|
[ 'opt_empty_p', %q{ [].empty? }, ],
|
||||||
[ 'opt_empty_p', %q{ {}.empty? }, ],
|
[ 'opt_empty_p', %q{ {}.empty? }, ],
|
||||||
[ 'opt_empty_p', %q{ Queue.new.empty? }, ],
|
[ 'opt_empty_p', %q{ Thread::Queue.new.empty? }, ],
|
||||||
|
|
||||||
[ 'opt_succ', %q{ 1.succ == 2 }, ],
|
[ 'opt_succ', %q{ 1.succ == 2 }, ],
|
||||||
if defined? $FIXNUM_MAX then
|
if defined? $FIXNUM_MAX then
|
||||||
|
@ -533,7 +533,7 @@ assert_equal '[RuntimeError, "ok", true]', %q{
|
|||||||
# threads in a ractor will killed
|
# threads in a ractor will killed
|
||||||
assert_equal '{:ok=>3}', %q{
|
assert_equal '{:ok=>3}', %q{
|
||||||
Ractor.new Ractor.current do |main|
|
Ractor.new Ractor.current do |main|
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
Thread.new do
|
Thread.new do
|
||||||
q << true
|
q << true
|
||||||
loop{}
|
loop{}
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
# def_delegators :@q, :clear, :first, :push, :shift, :size
|
# def_delegators :@q, :clear, :first, :push, :shift, :size
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# q = Queue.new
|
# q = Thread::Queue.new
|
||||||
# q.enq 1, 2, 3, 4, 5
|
# q.enq 1, 2, 3, 4, 5
|
||||||
# q.push 6
|
# q.push 6
|
||||||
#
|
#
|
||||||
|
@ -73,32 +73,32 @@ module Mutex_m
|
|||||||
mu_initialize
|
mu_initialize
|
||||||
end
|
end
|
||||||
|
|
||||||
# See Mutex#synchronize
|
# See Thread::Mutex#synchronize
|
||||||
def mu_synchronize(&block)
|
def mu_synchronize(&block)
|
||||||
@_mutex.synchronize(&block)
|
@_mutex.synchronize(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# See Mutex#locked?
|
# See Thread::Mutex#locked?
|
||||||
def mu_locked?
|
def mu_locked?
|
||||||
@_mutex.locked?
|
@_mutex.locked?
|
||||||
end
|
end
|
||||||
|
|
||||||
# See Mutex#try_lock
|
# See Thread::Mutex#try_lock
|
||||||
def mu_try_lock
|
def mu_try_lock
|
||||||
@_mutex.try_lock
|
@_mutex.try_lock
|
||||||
end
|
end
|
||||||
|
|
||||||
# See Mutex#lock
|
# See Thread::Mutex#lock
|
||||||
def mu_lock
|
def mu_lock
|
||||||
@_mutex.lock
|
@_mutex.lock
|
||||||
end
|
end
|
||||||
|
|
||||||
# See Mutex#unlock
|
# See Thread::Mutex#unlock
|
||||||
def mu_unlock
|
def mu_unlock
|
||||||
@_mutex.unlock
|
@_mutex.unlock
|
||||||
end
|
end
|
||||||
|
|
||||||
# See Mutex#sleep
|
# See Thread::Mutex#sleep
|
||||||
def sleep(timeout = nil)
|
def sleep(timeout = nil)
|
||||||
@_mutex.sleep(timeout)
|
@_mutex.sleep(timeout)
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ end
|
|||||||
|
|
||||||
class ChatServer
|
class ChatServer
|
||||||
def initialize
|
def initialize
|
||||||
@mutex = Mutex.new
|
@mutex = Thread::Mutex.new
|
||||||
@members = {}
|
@members = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class Scheduler
|
|||||||
|
|
||||||
@closed = false
|
@closed = false
|
||||||
|
|
||||||
@lock = Mutex.new
|
@lock = Thread::Mutex.new
|
||||||
@blocking = 0
|
@blocking = 0
|
||||||
@ready = []
|
@ready = []
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ class Scheduler
|
|||||||
Fiber.yield
|
Fiber.yield
|
||||||
end
|
end
|
||||||
|
|
||||||
# Used for Kernel#sleep and Mutex#sleep
|
# Used for Kernel#sleep and Thread::Mutex#sleep
|
||||||
def kernel_sleep(duration = nil)
|
def kernel_sleep(duration = nil)
|
||||||
# $stderr.puts [__method__, duration, Fiber.current].inspect
|
# $stderr.puts [__method__, duration, Fiber.current].inspect
|
||||||
|
|
||||||
@ -179,7 +179,8 @@ class Scheduler
|
|||||||
return true
|
return true
|
||||||
end
|
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)
|
def block(blocker, timeout = nil)
|
||||||
# $stderr.puts [__method__, blocker, timeout].inspect
|
# $stderr.puts [__method__, blocker, timeout].inspect
|
||||||
|
|
||||||
@ -201,7 +202,8 @@ class Scheduler
|
|||||||
end
|
end
|
||||||
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.
|
# This might be called from another thread.
|
||||||
def unblock(blocker, fiber)
|
def unblock(blocker, fiber)
|
||||||
# $stderr.puts [__method__, blocker, fiber].inspect
|
# $stderr.puts [__method__, blocker, fiber].inspect
|
||||||
|
@ -4,7 +4,7 @@ require_relative 'scheduler'
|
|||||||
|
|
||||||
class TestFiberMutex < Test::Unit::TestCase
|
class TestFiberMutex < Test::Unit::TestCase
|
||||||
def test_mutex_synchronize
|
def test_mutex_synchronize
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
|
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
scheduler = Scheduler.new
|
scheduler = Scheduler.new
|
||||||
@ -23,7 +23,7 @@ class TestFiberMutex < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_mutex_interleaved_locking
|
def test_mutex_interleaved_locking
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
|
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
scheduler = Scheduler.new
|
scheduler = Scheduler.new
|
||||||
@ -48,7 +48,7 @@ class TestFiberMutex < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_mutex_thread
|
def test_mutex_thread
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
mutex.lock
|
mutex.lock
|
||||||
|
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
@ -71,7 +71,7 @@ class TestFiberMutex < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_mutex_fiber_raise
|
def test_mutex_fiber_raise
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
ran = false
|
ran = false
|
||||||
|
|
||||||
main = Thread.new do
|
main = Thread.new do
|
||||||
@ -103,8 +103,8 @@ class TestFiberMutex < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condition_variable
|
def test_condition_variable
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condition = ConditionVariable.new
|
condition = Thread::ConditionVariable.new
|
||||||
|
|
||||||
signalled = 0
|
signalled = 0
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class TestFiberMutex < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue
|
def test_queue
|
||||||
queue = Queue.new
|
queue = Thread::Queue.new
|
||||||
processed = 0
|
processed = 0
|
||||||
|
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
@ -169,7 +169,7 @@ class TestFiberMutex < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_pop_waits
|
def test_queue_pop_waits
|
||||||
queue = Queue.new
|
queue = Thread::Queue.new
|
||||||
running = false
|
running = false
|
||||||
|
|
||||||
thread = Thread.new do
|
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
|
assert_in_out_err %W[-I#{__dir__} -], <<-RUBY, ['in synchronize'], error_pattern, success: false
|
||||||
require 'scheduler'
|
require 'scheduler'
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
|
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
scheduler = Scheduler.new
|
scheduler = Scheduler.new
|
||||||
|
@ -19,7 +19,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_enter
|
def test_enter
|
||||||
ary = []
|
ary = []
|
||||||
queue = Queue.new
|
queue = Thread::Queue.new
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
queue.pop
|
queue.pop
|
||||||
@monitor.enter
|
@monitor.enter
|
||||||
@ -83,7 +83,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_synchronize
|
def test_synchronize
|
||||||
ary = []
|
ary = []
|
||||||
queue = Queue.new
|
queue = Thread::Queue.new
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
queue.pop
|
queue.pop
|
||||||
@monitor.synchronize do
|
@monitor.synchronize do
|
||||||
@ -108,7 +108,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_killed_thread_in_synchronize
|
def test_killed_thread_in_synchronize
|
||||||
ary = []
|
ary = []
|
||||||
queue = Queue.new
|
queue = Thread::Queue.new
|
||||||
t1 = Thread.start {
|
t1 = Thread.start {
|
||||||
queue.pop
|
queue.pop
|
||||||
@monitor.synchronize {
|
@monitor.synchronize {
|
||||||
@ -136,8 +136,8 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_try_enter
|
def test_try_enter
|
||||||
queue1 = Queue.new
|
queue1 = Thread::Queue.new
|
||||||
queue2 = Queue.new
|
queue2 = Thread::Queue.new
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
queue1.deq
|
queue1.deq
|
||||||
@monitor.enter
|
@monitor.enter
|
||||||
@ -176,8 +176,8 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_mon_locked_and_owned
|
def test_mon_locked_and_owned
|
||||||
queue1 = Queue.new
|
queue1 = Thread::Queue.new
|
||||||
queue2 = Queue.new
|
queue2 = Thread::Queue.new
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
@monitor.enter
|
@monitor.enter
|
||||||
queue1.enq(nil)
|
queue1.enq(nil)
|
||||||
@ -210,7 +210,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
cond = @monitor.new_cond
|
cond = @monitor.new_cond
|
||||||
|
|
||||||
a = "foo"
|
a = "foo"
|
||||||
queue1 = Queue.new
|
queue1 = Thread::Queue.new
|
||||||
th = Thread.start do
|
th = Thread.start do
|
||||||
queue1.deq
|
queue1.deq
|
||||||
@monitor.synchronize do
|
@monitor.synchronize do
|
||||||
@ -262,7 +262,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
def test_timedwait
|
def test_timedwait
|
||||||
cond = @monitor.new_cond
|
cond = @monitor.new_cond
|
||||||
b = "foo"
|
b = "foo"
|
||||||
queue2 = Queue.new
|
queue2 = Thread::Queue.new
|
||||||
th = Thread.start do
|
th = Thread.start do
|
||||||
queue2.deq
|
queue2.deq
|
||||||
@monitor.synchronize do
|
@monitor.synchronize do
|
||||||
@ -282,7 +282,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
assert_join_threads([th, th2])
|
assert_join_threads([th, th2])
|
||||||
|
|
||||||
c = "foo"
|
c = "foo"
|
||||||
queue3 = Queue.new
|
queue3 = Thread::Queue.new
|
||||||
th = Thread.start do
|
th = Thread.start do
|
||||||
queue3.deq
|
queue3.deq
|
||||||
@monitor.synchronize do
|
@monitor.synchronize do
|
||||||
@ -312,7 +312,7 @@ class TestMonitor < Test::Unit::TestCase
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
# }
|
# }
|
||||||
# queue3 = Queue.new
|
# queue3 = Thread::Queue.new
|
||||||
# Thread.start do
|
# Thread.start do
|
||||||
# queue3.pop
|
# queue3.pop
|
||||||
# @monitor.synchronize do
|
# @monitor.synchronize do
|
||||||
|
@ -632,7 +632,7 @@ class TestBignum < Test::Unit::TestCase
|
|||||||
time = Time.now
|
time = Time.now
|
||||||
end_flag = false
|
end_flag = false
|
||||||
num = (65536 ** 65536)
|
num = (65536 ** 65536)
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
assert_raise(RuntimeError) {
|
assert_raise(RuntimeError) {
|
||||||
q << true
|
q << true
|
||||||
|
@ -131,7 +131,7 @@ class TestDir < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_chdir_conflict
|
def test_chdir_conflict
|
||||||
pwd = Dir.pwd
|
pwd = Dir.pwd
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
t = Thread.new do
|
t = Thread.new do
|
||||||
q.pop
|
q.pop
|
||||||
Dir.chdir(pwd) rescue $!
|
Dir.chdir(pwd) rescue $!
|
||||||
|
@ -814,7 +814,7 @@ end.join
|
|||||||
bug12741 = '[ruby-core:77222] [Bug #12741]'
|
bug12741 = '[ruby-core:77222] [Bug #12741]'
|
||||||
|
|
||||||
x = Thread.current
|
x = Thread.current
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
y = Thread.start do
|
y = Thread.start do
|
||||||
q.pop
|
q.pop
|
||||||
begin
|
begin
|
||||||
|
@ -3736,7 +3736,7 @@ __END__
|
|||||||
begin;
|
begin;
|
||||||
bug13158 = '[ruby-core:79262] [Bug #13158]'
|
bug13158 = '[ruby-core:79262] [Bug #13158]'
|
||||||
closed = nil
|
closed = nil
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
IO.pipe do |r, w|
|
IO.pipe do |r, w|
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
begin
|
begin
|
||||||
|
@ -2433,7 +2433,7 @@ EOS
|
|||||||
rescue SystemCallError
|
rescue SystemCallError
|
||||||
w.syswrite("exec failed\n")
|
w.syswrite("exec failed\n")
|
||||||
end
|
end
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
th1 = Thread.new { i = 0; i += 1 while q.empty?; i }
|
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 }
|
th2 = Thread.new { j = 0; j += 1 while q.empty? && Thread.pass.nil?; j }
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
|
@ -1984,7 +1984,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||||||
def test_thread_add_trace_func
|
def test_thread_add_trace_func
|
||||||
events = []
|
events = []
|
||||||
base_line = __LINE__
|
base_line = __LINE__
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
t = Thread.new{
|
t = Thread.new{
|
||||||
Thread.current.add_trace_func proc{|ev, file, line, *args|
|
Thread.current.add_trace_func proc{|ev, file, line, *args|
|
||||||
events << [ev, line]
|
events << [ev, line]
|
||||||
@ -2010,7 +2010,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||||||
|
|
||||||
# other thread
|
# other thread
|
||||||
events = []
|
events = []
|
||||||
m2t_q = Queue.new
|
m2t_q = Thread::Queue.new
|
||||||
|
|
||||||
t = Thread.new{
|
t = Thread.new{
|
||||||
Thread.current.abort_on_exception = true
|
Thread.current.abort_on_exception = true
|
||||||
@ -2320,8 +2320,8 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||||||
events << Thread.current
|
events << Thread.current
|
||||||
end
|
end
|
||||||
|
|
||||||
q1 = Queue.new
|
q1 = Thread::Queue.new
|
||||||
q2 = Queue.new
|
q2 = Thread::Queue.new
|
||||||
|
|
||||||
th = Thread.new{
|
th = Thread.new{
|
||||||
q1 << :ok; q2.pop
|
q1 << :ok; q2.pop
|
||||||
|
@ -496,7 +496,7 @@ class TestThread < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
assert_in_out_err([], <<-INPUT, %w(false :sig), [], :signal=>:INT, timeout: 1, timeout_error: nil)
|
assert_in_out_err([], <<-INPUT, %w(false :sig), [], :signal=>:INT, timeout: 1, timeout_error: nil)
|
||||||
p Thread.ignore_deadlock
|
p Thread.ignore_deadlock
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
trap(:INT){q.push :sig}
|
trap(:INT){q.push :sig}
|
||||||
Thread.ignore_deadlock = true
|
Thread.ignore_deadlock = true
|
||||||
p q.pop
|
p q.pop
|
||||||
@ -731,8 +731,8 @@ class TestThread < Test::Unit::TestCase
|
|||||||
|
|
||||||
def make_handle_interrupt_test_thread1 flag
|
def make_handle_interrupt_test_thread1 flag
|
||||||
r = []
|
r = []
|
||||||
ready_q = Queue.new
|
ready_q = Thread::Queue.new
|
||||||
done_q = Queue.new
|
done_q = Thread::Queue.new
|
||||||
th = Thread.new{
|
th = Thread.new{
|
||||||
begin
|
begin
|
||||||
Thread.handle_interrupt(RuntimeError => flag){
|
Thread.handle_interrupt(RuntimeError => flag){
|
||||||
@ -809,7 +809,7 @@ class TestThread < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_handle_interrupt_blocking
|
def test_handle_interrupt_blocking
|
||||||
r = nil
|
r = nil
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
e = Class.new(Exception)
|
e = Class.new(Exception)
|
||||||
th_s = Thread.current
|
th_s = Thread.current
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
@ -833,7 +833,7 @@ class TestThread < Test::Unit::TestCase
|
|||||||
def test_handle_interrupt_and_io
|
def test_handle_interrupt_and_io
|
||||||
assert_in_out_err([], <<-INPUT, %w(ok), [])
|
assert_in_out_err([], <<-INPUT, %w(ok), [])
|
||||||
th_waiting = true
|
th_waiting = true
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
|
|
||||||
t = Thread.new {
|
t = Thread.new {
|
||||||
Thread.current.report_on_exception = false
|
Thread.current.report_on_exception = false
|
||||||
@ -1235,7 +1235,7 @@ q.pop
|
|||||||
end if Process.respond_to?(:fork)
|
end if Process.respond_to?(:fork)
|
||||||
|
|
||||||
def test_fork_while_locked
|
def test_fork_while_locked
|
||||||
m = Mutex.new
|
m = Thread::Mutex.new
|
||||||
thrs = []
|
thrs = []
|
||||||
3.times do |i|
|
3.times do |i|
|
||||||
thrs << Thread.new { m.synchronize { Process.waitpid2(fork{})[1] } }
|
thrs << Thread.new { m.synchronize { Process.waitpid2(fork{})[1] } }
|
||||||
@ -1268,7 +1268,7 @@ q.pop
|
|||||||
|
|
||||||
def test_fork_while_mutex_locked_by_forker
|
def test_fork_while_mutex_locked_by_forker
|
||||||
skip 'needs fork' unless Process.respond_to?(:fork)
|
skip 'needs fork' unless Process.respond_to?(:fork)
|
||||||
m = Mutex.new
|
m = Thread::Mutex.new
|
||||||
m.synchronize do
|
m.synchronize do
|
||||||
pid = fork do
|
pid = fork do
|
||||||
exit!(2) unless m.locked?
|
exit!(2) unless m.locked?
|
||||||
|
@ -13,8 +13,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_signal_and_wait
|
def test_condvar_signal_and_wait
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
result = []
|
result = []
|
||||||
mutex.synchronize do
|
mutex.synchronize do
|
||||||
t = Thread.new do
|
t = Thread.new do
|
||||||
@ -35,8 +35,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
|
|||||||
def test_condvar_wait_exception_handling
|
def test_condvar_wait_exception_handling
|
||||||
# Calling wait in the only thread running should raise a ThreadError of
|
# Calling wait in the only thread running should raise a ThreadError of
|
||||||
# 'stopping only thread'
|
# 'stopping only thread'
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
|
|
||||||
locked = false
|
locked = false
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
@ -61,8 +61,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
|
|||||||
def test_condvar_wait_and_broadcast
|
def test_condvar_wait_and_broadcast
|
||||||
nr_threads = 3
|
nr_threads = 3
|
||||||
threads = Array.new
|
threads = Array.new
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
nr_threads.times do |i|
|
nr_threads.times do |i|
|
||||||
@ -91,8 +91,8 @@ class TestThreadConditionVariable < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_condvar_wait_deadlock
|
def test_condvar_wait_deadlock
|
||||||
assert_in_out_err([], <<-INPUT, /\Afatal\nNo live threads left\. Deadlock/, [])
|
assert_in_out_err([], <<-INPUT, /\Afatal\nNo live threads left\. Deadlock/, [])
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
cv = ConditionVariable.new
|
cv = Thread::ConditionVariable.new
|
||||||
|
|
||||||
klass = nil
|
klass = nil
|
||||||
mesg = nil
|
mesg = nil
|
||||||
@ -112,8 +112,8 @@ INPUT
|
|||||||
def test_condvar_wait_deadlock_2
|
def test_condvar_wait_deadlock_2
|
||||||
nr_threads = 3
|
nr_threads = 3
|
||||||
threads = Array.new
|
threads = Array.new
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
|
|
||||||
nr_threads.times do |i|
|
nr_threads.times do |i|
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
@ -136,8 +136,8 @@ INPUT
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_timed_wait
|
def test_condvar_timed_wait
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
timeout = 0.3
|
timeout = 0.3
|
||||||
locked = false
|
locked = false
|
||||||
|
|
||||||
@ -157,15 +157,15 @@ INPUT
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_nolock
|
def test_condvar_nolock
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
|
|
||||||
assert_raise(ThreadError) {condvar.wait(mutex)}
|
assert_raise(ThreadError) {condvar.wait(mutex)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_nolock_2
|
def test_condvar_nolock_2
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
assert_raise(ThreadError) {condvar.wait(mutex)}
|
assert_raise(ThreadError) {condvar.wait(mutex)}
|
||||||
@ -173,8 +173,8 @@ INPUT
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_nolock_3
|
def test_condvar_nolock_3
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
assert_raise(ThreadError) {condvar.wait(mutex, 0.1)}
|
assert_raise(ThreadError) {condvar.wait(mutex, 0.1)}
|
||||||
@ -182,22 +182,22 @@ INPUT
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_empty_signal
|
def test_condvar_empty_signal
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
|
|
||||||
assert_nothing_raised(Exception) { mutex.synchronize {condvar.signal} }
|
assert_nothing_raised(Exception) { mutex.synchronize {condvar.signal} }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_empty_broadcast
|
def test_condvar_empty_broadcast
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
|
|
||||||
assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} }
|
assert_nothing_raised(Exception) { mutex.synchronize {condvar.broadcast} }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dup
|
def test_dup
|
||||||
bug9440 = '[ruby-core:59961] [Bug #9440]'
|
bug9440 = '[ruby-core:59961] [Bug #9440]'
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
assert_raise(NoMethodError, bug9440) do
|
assert_raise(NoMethodError, bug9440) do
|
||||||
condvar.dup
|
condvar.dup
|
||||||
end
|
end
|
||||||
@ -207,7 +207,7 @@ INPUT
|
|||||||
|
|
||||||
def test_dump
|
def test_dump
|
||||||
bug9674 = '[ruby-core:61677] [Bug #9674]'
|
bug9674 = '[ruby-core:61677] [Bug #9674]'
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do
|
assert_raise_with_message(TypeError, /#{ConditionVariable}/, bug9674) do
|
||||||
Marshal.dump(condvar)
|
Marshal.dump(condvar)
|
||||||
end
|
end
|
||||||
@ -219,8 +219,8 @@ INPUT
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_condvar_fork
|
def test_condvar_fork
|
||||||
mutex = Mutex.new
|
mutex = Thread::Mutex.new
|
||||||
condvar = ConditionVariable.new
|
condvar = Thread::ConditionVariable.new
|
||||||
thrs = (1..10).map do
|
thrs = (1..10).map do
|
||||||
Thread.new { mutex.synchronize { condvar.wait(mutex) } }
|
Thread.new { mutex.synchronize { condvar.wait(mutex) } }
|
||||||
end
|
end
|
||||||
|
@ -66,7 +66,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
[e, "Enumerable"],
|
[e, "Enumerable"],
|
||||||
[Struct.new(:to_a), "Array-like"],
|
[Struct.new(:to_a), "Array-like"],
|
||||||
) do |a, type|
|
) 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_equal(3, q.size, type)
|
||||||
assert_not_predicate(q, :empty?, type)
|
assert_not_predicate(q, :empty?, type)
|
||||||
assert_equal(1, q.pop, type)
|
assert_equal(1, q.pop, type)
|
||||||
@ -77,14 +77,14 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_initialize
|
def test_sized_queue_initialize
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
assert_equal 1, q.max
|
assert_equal 1, q.max
|
||||||
assert_raise(ArgumentError) { SizedQueue.new(0) }
|
assert_raise(ArgumentError) { Thread::SizedQueue.new(0) }
|
||||||
assert_raise(ArgumentError) { SizedQueue.new(-1) }
|
assert_raise(ArgumentError) { Thread::SizedQueue.new(-1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_assign_max
|
def test_sized_queue_assign_max
|
||||||
q = SizedQueue.new(2)
|
q = Thread::SizedQueue.new(2)
|
||||||
assert_equal(2, q.max)
|
assert_equal(2, q.max)
|
||||||
q.max = 1
|
q.max = 1
|
||||||
assert_equal(1, q.max)
|
assert_equal(1, q.max)
|
||||||
@ -104,7 +104,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_pop_interrupt
|
def test_queue_pop_interrupt
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
t1 = Thread.new { q.pop }
|
t1 = Thread.new { q.pop }
|
||||||
sleep 0.01 until t1.stop?
|
sleep 0.01 until t1.stop?
|
||||||
t1.kill.join
|
t1.kill.join
|
||||||
@ -112,14 +112,14 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_pop_non_block
|
def test_queue_pop_non_block
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
assert_raise_with_message(ThreadError, /empty/) do
|
assert_raise_with_message(ThreadError, /empty/) do
|
||||||
q.pop(true)
|
q.pop(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_pop_interrupt
|
def test_sized_queue_pop_interrupt
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
t1 = Thread.new { q.pop }
|
t1 = Thread.new { q.pop }
|
||||||
sleep 0.01 until t1.stop?
|
sleep 0.01 until t1.stop?
|
||||||
t1.kill.join
|
t1.kill.join
|
||||||
@ -127,14 +127,14 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_pop_non_block
|
def test_sized_queue_pop_non_block
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
assert_raise_with_message(ThreadError, /empty/) do
|
assert_raise_with_message(ThreadError, /empty/) do
|
||||||
q.pop(true)
|
q.pop(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_push_interrupt
|
def test_sized_queue_push_interrupt
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
q.push(1)
|
q.push(1)
|
||||||
assert_raise_with_message(ThreadError, /full/) do
|
assert_raise_with_message(ThreadError, /full/) do
|
||||||
q.push(2, true)
|
q.push(2, true)
|
||||||
@ -142,7 +142,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_push_non_block
|
def test_sized_queue_push_non_block
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
q.push(1)
|
q.push(1)
|
||||||
t1 = Thread.new { q.push(2) }
|
t1 = Thread.new { q.push(2) }
|
||||||
sleep 0.01 until t1.stop?
|
sleep 0.01 until t1.stop?
|
||||||
@ -159,7 +159,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
assert_normal_exit(<<-"_eom", bug5343, **{:timeout => timeout, :chdir=>d})
|
assert_normal_exit(<<-"_eom", bug5343, **{:timeout => timeout, :chdir=>d})
|
||||||
#{total_count}.times do |i|
|
#{total_count}.times do |i|
|
||||||
open("test_thr_kill_count", "w") {|f| f.puts i }
|
open("test_thr_kill_count", "w") {|f| f.puts i }
|
||||||
queue = Queue.new
|
queue = Thread::Queue.new
|
||||||
r, w = IO.pipe
|
r, w = IO.pipe
|
||||||
th = Thread.start {
|
th = Thread.start {
|
||||||
queue.push(nil)
|
queue.push(nil)
|
||||||
@ -178,20 +178,20 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_push_return_value
|
def test_queue_push_return_value
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
retval = q.push(1)
|
retval = q.push(1)
|
||||||
assert_same q, retval
|
assert_same q, retval
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_clear_return_value
|
def test_queue_clear_return_value
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
retval = q.clear
|
retval = q.clear
|
||||||
assert_same q, retval
|
assert_same q, retval
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_clear
|
def test_sized_queue_clear
|
||||||
# Fill queue, then test that SizedQueue#clear wakes up all waiting threads
|
# Fill queue, then test that Thread::SizedQueue#clear wakes up all waiting threads
|
||||||
sq = SizedQueue.new(2)
|
sq = Thread::SizedQueue.new(2)
|
||||||
2.times { sq << 1 }
|
2.times { sq << 1 }
|
||||||
|
|
||||||
t1 = Thread.new do
|
t1 = Thread.new do
|
||||||
@ -212,19 +212,19 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_push_return_value
|
def test_sized_queue_push_return_value
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
retval = q.push(1)
|
retval = q.push(1)
|
||||||
assert_same q, retval
|
assert_same q, retval
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_clear_return_value
|
def test_sized_queue_clear_return_value
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
retval = q.clear
|
retval = q.clear
|
||||||
assert_same q, retval
|
assert_same q, retval
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_throttle
|
def test_sized_queue_throttle
|
||||||
q = SizedQueue.new(1)
|
q = Thread::SizedQueue.new(1)
|
||||||
i = 0
|
i = 0
|
||||||
consumer = Thread.new do
|
consumer = Thread.new do
|
||||||
while q.pop
|
while q.pop
|
||||||
@ -247,7 +247,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_thread_raise
|
def test_queue_thread_raise
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
th1 = Thread.new do
|
th1 = Thread.new do
|
||||||
begin
|
begin
|
||||||
q.pop
|
q.pop
|
||||||
@ -277,7 +277,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_dup
|
def test_dup
|
||||||
bug9440 = '[ruby-core:59961] [Bug #9440]'
|
bug9440 = '[ruby-core:59961] [Bug #9440]'
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
assert_raise(NoMethodError, bug9440) do
|
assert_raise(NoMethodError, bug9440) do
|
||||||
q.dup
|
q.dup
|
||||||
end
|
end
|
||||||
@ -287,12 +287,12 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_dump
|
def test_dump
|
||||||
bug9674 = '[ruby-core:61677] [Bug #9674]'
|
bug9674 = '[ruby-core:61677] [Bug #9674]'
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
assert_raise_with_message(TypeError, /#{Queue}/, bug9674) do
|
assert_raise_with_message(TypeError, /#{Queue}/, bug9674) do
|
||||||
Marshal.dump(q)
|
Marshal.dump(q)
|
||||||
end
|
end
|
||||||
|
|
||||||
sq = SizedQueue.new(1)
|
sq = Thread::SizedQueue.new(1)
|
||||||
assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do
|
assert_raise_with_message(TypeError, /#{SizedQueue}/, bug9674) do
|
||||||
Marshal.dump(sq)
|
Marshal.dump(sq)
|
||||||
end
|
end
|
||||||
@ -304,7 +304,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_close
|
def test_close
|
||||||
[->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
|
[->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate|
|
||||||
q = qcreate.call
|
q = qcreate.call
|
||||||
assert_equal false, q.closed?
|
assert_equal false, q.closed?
|
||||||
q << :something
|
q << :something
|
||||||
@ -343,15 +343,15 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_close_wakeup
|
def test_queue_close_wakeup
|
||||||
close_wakeup(15, 18){Queue.new}
|
close_wakeup(15, 18){Thread::Queue.new}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_size_queue_close_wakeup
|
def test_size_queue_close_wakeup
|
||||||
close_wakeup(5, 8){SizedQueue.new 9}
|
close_wakeup(5, 8){Thread::SizedQueue.new 9}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_one_closed_interrupt
|
def test_sized_queue_one_closed_interrupt
|
||||||
q = SizedQueue.new 1
|
q = Thread::SizedQueue.new 1
|
||||||
q << :one
|
q << :one
|
||||||
t1 = Thread.new {
|
t1 = Thread.new {
|
||||||
Thread.current.report_on_exception = false
|
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
|
# make sure that shutdown state is handled properly by empty? for the non-blocking case
|
||||||
def test_empty_non_blocking
|
def test_empty_non_blocking
|
||||||
q = SizedQueue.new 3
|
q = Thread::SizedQueue.new 3
|
||||||
3.times{|i| q << i}
|
3.times{|i| q << i}
|
||||||
|
|
||||||
# these all block cos the queue is full
|
# these all block cos the queue is full
|
||||||
@ -394,13 +394,13 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_sized_queue_closed_push_non_blocking
|
def test_sized_queue_closed_push_non_blocking
|
||||||
q = SizedQueue.new 7
|
q = Thread::SizedQueue.new 7
|
||||||
q.close
|
q.close
|
||||||
assert_raise_with_message(ClosedQueueError, /queue closed/){q.push(non_block=true)}
|
assert_raise_with_message(ClosedQueueError, /queue closed/){q.push(non_block=true)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_blocked_pushers
|
def test_blocked_pushers
|
||||||
q = SizedQueue.new 3
|
q = Thread::SizedQueue.new 3
|
||||||
prod_threads = 6.times.map do |i|
|
prod_threads = 6.times.map do |i|
|
||||||
thr = Thread.new{
|
thr = Thread.new{
|
||||||
Thread.current.report_on_exception = false
|
Thread.current.report_on_exception = false
|
||||||
@ -446,9 +446,9 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_deny_pushers
|
def test_deny_pushers
|
||||||
[->{Queue.new}, ->{SizedQueue.new 3}].each do |qcreate|
|
[->{Thread::Queue.new}, ->{Thread::SizedQueue.new 3}].each do |qcreate|
|
||||||
q = qcreate[]
|
q = qcreate[]
|
||||||
synq = Queue.new
|
synq = Thread::Queue.new
|
||||||
prod_threads = 20.times.map do |i|
|
prod_threads = 20.times.map do |i|
|
||||||
Thread.new {
|
Thread.new {
|
||||||
synq.pop
|
synq.pop
|
||||||
@ -466,7 +466,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
|
|
||||||
# size should account for waiting pushers during shutdown
|
# size should account for waiting pushers during shutdown
|
||||||
def sized_queue_size_close
|
def sized_queue_size_close
|
||||||
q = SizedQueue.new 4
|
q = Thread::SizedQueue.new 4
|
||||||
4.times{|i| q << i}
|
4.times{|i| q << i}
|
||||||
Thread.new{ q << 5 }
|
Thread.new{ q << 5 }
|
||||||
Thread.new{ q << 6 }
|
Thread.new{ q << 6 }
|
||||||
@ -478,7 +478,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_blocked_pushers_empty
|
def test_blocked_pushers_empty
|
||||||
q = SizedQueue.new 3
|
q = Thread::SizedQueue.new 3
|
||||||
prod_threads = 6.times.map do |i|
|
prod_threads = 6.times.map do |i|
|
||||||
Thread.new{
|
Thread.new{
|
||||||
Thread.current.report_on_exception = false
|
Thread.current.report_on_exception = false
|
||||||
@ -510,14 +510,14 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
|
|
||||||
# test thread wakeup on one-element SizedQueue with close
|
# test thread wakeup on one-element SizedQueue with close
|
||||||
def test_one_element_sized_queue
|
def test_one_element_sized_queue
|
||||||
q = SizedQueue.new 1
|
q = Thread::SizedQueue.new 1
|
||||||
t = Thread.new{ q.pop }
|
t = Thread.new{ q.pop }
|
||||||
q.close
|
q.close
|
||||||
assert_nil t.value
|
assert_nil t.value
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_close_twice
|
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 = qcreate[]
|
||||||
q.close
|
q.close
|
||||||
assert_nothing_raised(ClosedQueueError){q.close}
|
assert_nothing_raised(ClosedQueueError){q.close}
|
||||||
@ -525,7 +525,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_queue_close_multi_multi
|
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_items = rand(3000..5000)
|
||||||
count_producers = rand(10..20)
|
count_producers = rand(10..20)
|
||||||
@ -587,7 +587,7 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert_in_out_err([], <<-INPUT, %w(INT INT exit), [])
|
assert_in_out_err([], <<-INPUT, %w(INT INT exit), [])
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
trap(:INT){
|
trap(:INT){
|
||||||
q.push 'INT'
|
q.push 'INT'
|
||||||
}
|
}
|
||||||
@ -604,8 +604,8 @@ class TestThreadQueue < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_fork_while_queue_waiting
|
def test_fork_while_queue_waiting
|
||||||
q = Queue.new
|
q = Thread::Queue.new
|
||||||
sq = SizedQueue.new(1)
|
sq = Thread::SizedQueue.new(1)
|
||||||
thq = Thread.new { q.pop }
|
thq = Thread.new { q.pop }
|
||||||
thsq = Thread.new { sq.pop }
|
thsq = Thread.new { sq.pop }
|
||||||
Thread.pass until thq.stop? && thsq.stop?
|
Thread.pass until thq.stop? && thsq.stop?
|
||||||
|
@ -75,7 +75,7 @@ class PStoreTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_thread_safe
|
def test_thread_safe
|
||||||
q1 = Queue.new
|
q1 = Thread::Queue.new
|
||||||
assert_raise(PStore::Error) do
|
assert_raise(PStore::Error) do
|
||||||
th = Thread.new do
|
th = Thread.new do
|
||||||
@pstore.transaction do
|
@pstore.transaction do
|
||||||
@ -92,7 +92,7 @@ class PStoreTest < Test::Unit::TestCase
|
|||||||
th.join
|
th.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
q2 = Queue.new
|
q2 = Thread::Queue.new
|
||||||
begin
|
begin
|
||||||
pstore = PStore.new(second_file, true)
|
pstore = PStore.new(second_file, true)
|
||||||
cur = Thread.current
|
cur = Thread.current
|
||||||
|
@ -75,7 +75,7 @@ class YAMLStoreTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_thread_safe
|
def test_thread_safe
|
||||||
q1 = Queue.new
|
q1 = Thread::Queue.new
|
||||||
assert_raise(PStore::Error) do
|
assert_raise(PStore::Error) do
|
||||||
th = Thread.new do
|
th = Thread.new do
|
||||||
@yaml_store.transaction do
|
@yaml_store.transaction do
|
||||||
@ -92,7 +92,7 @@ class YAMLStoreTest < Test::Unit::TestCase
|
|||||||
th.join
|
th.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
q2 = Queue.new
|
q2 = Thread::Queue.new
|
||||||
begin
|
begin
|
||||||
yaml_store = YAML::Store.new(second_file, true)
|
yaml_store = YAML::Store.new(second_file, true)
|
||||||
cur = Thread.current
|
cur = Thread.current
|
||||||
|
2
thread.c
2
thread.c
@ -3153,7 +3153,7 @@ rb_thread_s_ignore_deadlock(VALUE _)
|
|||||||
* deadlock condition via some other means, such as a signal.
|
* deadlock condition via some other means, such as a signal.
|
||||||
*
|
*
|
||||||
* Thread.ignore_deadlock = true
|
* Thread.ignore_deadlock = true
|
||||||
* queue = Queue.new
|
* queue = Thread::Queue.new
|
||||||
*
|
*
|
||||||
* trap(:SIGUSR1){queue.push "Received signal"}
|
* trap(:SIGUSR1){queue.push "Received signal"}
|
||||||
*
|
*
|
||||||
|
@ -65,14 +65,14 @@ static void rb_mutex_abandon_locking_mutex(rb_thread_t *th);
|
|||||||
static const char* rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th, rb_fiber_t *fiber);
|
static const char* rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th, rb_fiber_t *fiber);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-class: Mutex
|
* Document-class: Thread::Mutex
|
||||||
*
|
*
|
||||||
* Mutex implements a simple semaphore that can be used to coordinate access to
|
* Thread::Mutex implements a simple semaphore that can be used to
|
||||||
* shared data from multiple concurrent threads.
|
* coordinate access to shared data from multiple concurrent threads.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* semaphore = Mutex.new
|
* semaphore = Thread::Mutex.new
|
||||||
*
|
*
|
||||||
* a = Thread.new {
|
* a = Thread.new {
|
||||||
* semaphore.synchronize {
|
* semaphore.synchronize {
|
||||||
@ -164,7 +164,7 @@ mutex_alloc(VALUE klass)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Mutex.new -> mutex
|
* Thread::Mutex.new -> mutex
|
||||||
*
|
*
|
||||||
* Creates a new Mutex
|
* Creates a new Mutex
|
||||||
*/
|
*/
|
||||||
@ -600,7 +600,7 @@ mutex_sleep(int argc, VALUE *argv, VALUE self)
|
|||||||
* mutex.synchronize { ... } -> result of the block
|
* mutex.synchronize { ... } -> result of the block
|
||||||
*
|
*
|
||||||
* Obtains a lock, runs the block, and releases the lock when the block
|
* Obtains a lock, runs the block, and releases the lock when the block
|
||||||
* completes. See the example under +Mutex+.
|
* completes. See the example under Thread::Mutex.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -615,7 +615,7 @@ rb_mutex_synchronize(VALUE mutex, VALUE (*func)(VALUE arg), VALUE arg)
|
|||||||
* mutex.synchronize { ... } -> result of the block
|
* mutex.synchronize { ... } -> result of the block
|
||||||
*
|
*
|
||||||
* Obtains a lock, runs the block, and releases the lock when the block
|
* Obtains a lock, runs the block, and releases the lock when the block
|
||||||
* completes. See the example under +Mutex+.
|
* completes. See the example under Thread::Mutex.
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_mutex_synchronize_m(VALUE self)
|
rb_mutex_synchronize_m(VALUE self)
|
||||||
@ -792,7 +792,7 @@ queue_closed_p(VALUE self)
|
|||||||
* Document-class: ClosedQueueError
|
* Document-class: ClosedQueueError
|
||||||
*
|
*
|
||||||
* The exception class which will be raised when pushing into a closed
|
* The exception class which will be raised when pushing into a closed
|
||||||
* Queue. See Queue#close and SizedQueue#close.
|
* Queue. See Thread::Queue#close and Thread::SizedQueue#close.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NORETURN(static void raise_closed_queue_error(VALUE self));
|
NORETURN(static void raise_closed_queue_error(VALUE self));
|
||||||
@ -811,19 +811,19 @@ queue_closed_result(VALUE self, struct rb_queue *q)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-class: Queue
|
* Document-class: Thread::Queue
|
||||||
*
|
*
|
||||||
* The Queue class implements multi-producer, multi-consumer queues.
|
* The Thread::Queue class implements multi-producer, multi-consumer
|
||||||
* It is especially useful in threaded programming when information
|
* queues. It is especially useful in threaded programming when
|
||||||
* must be exchanged safely between multiple threads. The Queue class
|
* information must be exchanged safely between multiple threads. The
|
||||||
* implements all the required locking semantics.
|
* Thread::Queue class implements all the required locking semantics.
|
||||||
*
|
*
|
||||||
* The class implements FIFO type of queue. In a FIFO queue, the first
|
* The class implements FIFO type of queue. In a FIFO queue, the first
|
||||||
* tasks added are the first retrieved.
|
* tasks added are the first retrieved.
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* queue = Queue.new
|
* queue = Thread::Queue.new
|
||||||
*
|
*
|
||||||
* producer = Thread.new do
|
* producer = Thread.new do
|
||||||
* 5.times do |i|
|
* 5.times do |i|
|
||||||
@ -853,9 +853,9 @@ queue_closed_result(VALUE self, struct rb_queue *q)
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* q = Queue.new
|
* q = Thread::Queue.new
|
||||||
* q = Queue.new([a, b, c])
|
* q = Thread::Queue.new([a, b, c])
|
||||||
* q = Queue.new(items)
|
* q = Thread::Queue.new(items)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -886,7 +886,7 @@ queue_do_push(VALUE self, struct rb_queue *q, VALUE obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#close
|
* Document-method: Thread::Queue#close
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* close
|
* close
|
||||||
*
|
*
|
||||||
@ -909,7 +909,7 @@ queue_do_push(VALUE self, struct rb_queue *q, VALUE obj)
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* q = Queue.new
|
* q = Thread::Queue.new
|
||||||
* Thread.new{
|
* Thread.new{
|
||||||
* while e = q.deq # wait for nil to break loop
|
* while e = q.deq # wait for nil to break loop
|
||||||
* # ...
|
* # ...
|
||||||
@ -933,7 +933,7 @@ rb_queue_close(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#closed?
|
* Document-method: Thread::Queue#closed?
|
||||||
* call-seq: closed?
|
* call-seq: closed?
|
||||||
*
|
*
|
||||||
* Returns +true+ if the queue is closed.
|
* Returns +true+ if the queue is closed.
|
||||||
@ -946,7 +946,7 @@ rb_queue_closed_p(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#push
|
* Document-method: Thread::Queue#push
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* push(object)
|
* push(object)
|
||||||
* enq(object)
|
* enq(object)
|
||||||
@ -1049,7 +1049,7 @@ queue_pop_should_block(int argc, const VALUE *argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#pop
|
* Document-method: Thread::Queue#pop
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* pop(non_block=false)
|
* pop(non_block=false)
|
||||||
* deq(non_block=false)
|
* deq(non_block=false)
|
||||||
@ -1070,7 +1070,7 @@ rb_queue_pop(int argc, VALUE *argv, VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#empty?
|
* Document-method: Thread::Queue#empty?
|
||||||
* call-seq: empty?
|
* call-seq: empty?
|
||||||
*
|
*
|
||||||
* Returns +true+ if the queue is empty.
|
* Returns +true+ if the queue is empty.
|
||||||
@ -1083,7 +1083,7 @@ rb_queue_empty_p(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#clear
|
* Document-method: Thread::Queue#clear
|
||||||
*
|
*
|
||||||
* Removes all objects from the queue.
|
* Removes all objects from the queue.
|
||||||
*/
|
*/
|
||||||
@ -1098,7 +1098,7 @@ rb_queue_clear(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#length
|
* Document-method: Thread::Queue#length
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* length
|
* length
|
||||||
* size
|
* size
|
||||||
@ -1113,7 +1113,7 @@ rb_queue_length(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: Queue#num_waiting
|
* Document-method: Thread::Queue#num_waiting
|
||||||
*
|
*
|
||||||
* Returns the number of threads waiting on the queue.
|
* Returns the number of threads waiting on the queue.
|
||||||
*/
|
*/
|
||||||
@ -1127,12 +1127,12 @@ rb_queue_num_waiting(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-class: SizedQueue
|
* Document-class: Thread::SizedQueue
|
||||||
*
|
*
|
||||||
* This class represents queues of specified size capacity. The push operation
|
* This class represents queues of specified size capacity. The push operation
|
||||||
* may be blocked if the capacity is full.
|
* may be blocked if the capacity is full.
|
||||||
*
|
*
|
||||||
* See Queue for an example of how a SizedQueue works.
|
* See Thread::Queue for an example of how a Thread::SizedQueue works.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1162,11 +1162,11 @@ rb_szqueue_initialize(VALUE self, VALUE vmax)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#close
|
* Document-method: Thread::SizedQueue#close
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* close
|
* close
|
||||||
*
|
*
|
||||||
* Similar to Queue#close.
|
* Similar to Thread::Queue#close.
|
||||||
*
|
*
|
||||||
* The difference is behavior with waiting enqueuing threads.
|
* The difference is behavior with waiting enqueuing threads.
|
||||||
*
|
*
|
||||||
@ -1187,7 +1187,7 @@ rb_szqueue_close(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#max
|
* Document-method: Thread::SizedQueue#max
|
||||||
*
|
*
|
||||||
* Returns the maximum size of the queue.
|
* Returns the maximum size of the queue.
|
||||||
*/
|
*/
|
||||||
@ -1199,7 +1199,7 @@ rb_szqueue_max_get(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#max=
|
* Document-method: Thread::SizedQueue#max=
|
||||||
* call-seq: max=(number)
|
* call-seq: max=(number)
|
||||||
*
|
*
|
||||||
* Sets the maximum size of the queue to the given +number+.
|
* Sets the maximum size of the queue to the given +number+.
|
||||||
@ -1235,7 +1235,7 @@ szqueue_push_should_block(int argc, const VALUE *argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#push
|
* Document-method: Thread::SizedQueue#push
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* push(object, non_block=false)
|
* push(object, non_block=false)
|
||||||
* enq(object, non_block=false)
|
* enq(object, non_block=false)
|
||||||
@ -1299,7 +1299,7 @@ szqueue_do_pop(VALUE self, int should_block)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#pop
|
* Document-method: Thread::SizedQueue#pop
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* pop(non_block=false)
|
* pop(non_block=false)
|
||||||
* deq(non_block=false)
|
* deq(non_block=false)
|
||||||
@ -1320,7 +1320,7 @@ rb_szqueue_pop(int argc, VALUE *argv, VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#clear
|
* Document-method: Thread::SizedQueue#clear
|
||||||
*
|
*
|
||||||
* Removes all objects from the queue.
|
* Removes all objects from the queue.
|
||||||
*/
|
*/
|
||||||
@ -1336,7 +1336,7 @@ rb_szqueue_clear(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#length
|
* Document-method: Thread::SizedQueue#length
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* length
|
* length
|
||||||
* size
|
* size
|
||||||
@ -1353,7 +1353,7 @@ rb_szqueue_length(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#num_waiting
|
* Document-method: Thread::SizedQueue#num_waiting
|
||||||
*
|
*
|
||||||
* Returns the number of threads waiting on the queue.
|
* Returns the number of threads waiting on the queue.
|
||||||
*/
|
*/
|
||||||
@ -1367,7 +1367,7 @@ rb_szqueue_num_waiting(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: SizedQueue#empty?
|
* Document-method: Thread::SizedQueue#empty?
|
||||||
* call-seq: empty?
|
* call-seq: empty?
|
||||||
*
|
*
|
||||||
* Returns +true+ if the queue is empty.
|
* Returns +true+ if the queue is empty.
|
||||||
@ -1389,7 +1389,7 @@ struct rb_condvar {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-class: ConditionVariable
|
* Document-class: Thread::ConditionVariable
|
||||||
*
|
*
|
||||||
* ConditionVariable objects augment class Mutex. Using condition variables,
|
* ConditionVariable objects augment class Mutex. Using condition variables,
|
||||||
* it is possible to suspend while in the middle of a critical section until a
|
* it is possible to suspend while in the middle of a critical section until a
|
||||||
@ -1397,8 +1397,8 @@ struct rb_condvar {
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* mutex = Mutex.new
|
* mutex = Thread::Mutex.new
|
||||||
* resource = ConditionVariable.new
|
* resource = Thread::ConditionVariable.new
|
||||||
*
|
*
|
||||||
* a = Thread.new {
|
* a = Thread.new {
|
||||||
* mutex.synchronize {
|
* mutex.synchronize {
|
||||||
@ -1486,7 +1486,7 @@ do_sleep(VALUE args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: ConditionVariable#wait
|
* Document-method: Thread::ConditionVariable#wait
|
||||||
* call-seq: wait(mutex, timeout=nil)
|
* call-seq: wait(mutex, timeout=nil)
|
||||||
*
|
*
|
||||||
* Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
|
* Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
|
||||||
@ -1517,7 +1517,7 @@ rb_condvar_wait(int argc, VALUE *argv, VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: ConditionVariable#signal
|
* Document-method: Thread::ConditionVariable#signal
|
||||||
*
|
*
|
||||||
* Wakes up the first thread in line waiting for this lock.
|
* Wakes up the first thread in line waiting for this lock.
|
||||||
*/
|
*/
|
||||||
@ -1531,7 +1531,7 @@ rb_condvar_signal(VALUE self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Document-method: ConditionVariable#broadcast
|
* Document-method: Thread::ConditionVariable#broadcast
|
||||||
*
|
*
|
||||||
* Wakes up all threads waiting for this lock.
|
* Wakes up all threads waiting for this lock.
|
||||||
*/
|
*/
|
||||||
@ -1565,11 +1565,11 @@ static void
|
|||||||
Init_thread_sync(void)
|
Init_thread_sync(void)
|
||||||
{
|
{
|
||||||
#undef rb_intern
|
#undef rb_intern
|
||||||
#if 0
|
#if defined(TEACH_RDOC) && TEACH_RDOC == 42
|
||||||
rb_cMutex = rb_define_class("Mutex", rb_cObject); /* teach rdoc Mutex */
|
rb_cMutex = rb_define_class_under(rb_cThread, "Mutex", rb_cObject);
|
||||||
rb_cConditionVariable = rb_define_class("ConditionVariable", rb_cObject); /* teach rdoc ConditionVariable */
|
rb_cConditionVariable = rb_define_class_under(rb_cThread, "ConditionVariable", rb_cObject);
|
||||||
rb_cQueue = rb_define_class("Queue", rb_cObject); /* teach rdoc Queue */
|
rb_cQueue = rb_define_class_under(rb_cThread, "Queue", rb_cObject);
|
||||||
rb_cSizedQueue = rb_define_class("SizedQueue", rb_cObject); /* teach rdoc SizedQueue */
|
rb_cSizedQueue = rb_define_class_under(rb_cThread, "SizedQueue", rb_cObject);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFINE_CLASS(name, super) \
|
#define DEFINE_CLASS(name, super) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user