summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-30 06:22:30 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-30 06:22:30 (GMT)
commit4b298ad77a8388f0aae62daeca66659a8effeade (patch)
tree163674f4123bf461a86b4f6fd1de964297057bae
parent0df79477bd2cd534ad2d89bfdbf9708c64b59eed (diff)
Use qualified names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--benchmark/bm_vm2_mutex.rb2
-rw-r--r--benchmark/bm_vm_thread_mutex1.rb2
-rw-r--r--benchmark/bm_vm_thread_mutex2.rb2
-rw-r--r--benchmark/bm_vm_thread_mutex3.rb2
-rw-r--r--benchmark/bm_vm_thread_queue.rb2
-rw-r--r--bootstraptest/test_objectspace.rb2
-rw-r--r--bootstraptest/test_thread.rb18
-rw-r--r--ext/digest/lib/digest.rb2
-rw-r--r--lib/debug.rb2
-rw-r--r--lib/drb/drb.rb4
-rw-r--r--lib/drb/extservm.rb2
-rw-r--r--lib/irb/workspace.rb2
-rw-r--r--lib/monitor.rb4
-rw-r--r--lib/mutex_m.rb2
-rw-r--r--lib/pstore.rb2
-rw-r--r--lib/resolv.rb8
-rw-r--r--lib/rinda/ring.rb2
-rw-r--r--lib/rinda/tuplespace.rb2
-rw-r--r--lib/shell.rb4
-rw-r--r--lib/shell/process-controller.rb16
-rw-r--r--lib/shell/system-command.rb2
-rw-r--r--lib/singleton.rb2
-rw-r--r--lib/sync.rb2
-rw-r--r--lib/thwait.rb2
-rw-r--r--lib/tracer.rb2
-rw-r--r--lib/webrick/httpauth/digestauth.rb2
-rw-r--r--lib/webrick/httpauth/htdigest.rb2
-rw-r--r--lib/webrick/server.rb2
-rw-r--r--lib/webrick/utils.rb4
-rw-r--r--prelude.rb5
-rw-r--r--sample/drb/dhasen.rb2
-rw-r--r--sample/drb/dlogd.rb2
-rw-r--r--sample/drb/dqueue.rb2
-rw-r--r--sample/drb/http0serv.rb4
-rw-r--r--sample/drb/name.rb4
-rw-r--r--sample/philos.rb2
-rw-r--r--test/lib/minitest/unit.rb2
-rw-r--r--test/monitor/test_monitor.rb2
-rw-r--r--test/ruby/lbtest.rb4
-rw-r--r--test/ruby/test_backtrace.rb4
-rw-r--r--test/ruby/test_file.rb4
-rw-r--r--test/ruby/test_regexp.rb2
-rw-r--r--test/ruby/test_thread.rb34
-rw-r--r--test/ruby/test_time.rb2
-rw-r--r--test/socket/test_unix.rb2
-rw-r--r--test/test_mutex_m.rb2
-rw-r--r--test/test_tempfile.rb4
-rw-r--r--test/test_timeout.rb2
-rw-r--r--test/thread/test_cv.rb3
-rw-r--r--test/thread/test_queue.rb3
50 files changed, 100 insertions, 93 deletions
diff --git a/benchmark/bm_vm2_mutex.rb b/benchmark/bm_vm2_mutex.rb
index 7362f73..5d16480 100644
--- a/benchmark/bm_vm2_mutex.rb
+++ b/benchmark/bm_vm2_mutex.rb
@@ -1,6 +1,6 @@
require 'thread'
-m = Mutex.new
+m = Thread::Mutex.new
i = 0
while i<6_000_000 # benchmark loop 2
diff --git a/benchmark/bm_vm_thread_mutex1.rb b/benchmark/bm_vm_thread_mutex1.rb
index 5c9f85d..66e42c8 100644
--- a/benchmark/bm_vm_thread_mutex1.rb
+++ b/benchmark/bm_vm_thread_mutex1.rb
@@ -1,7 +1,7 @@
# one thread, one mutex (no contention)
require 'thread'
-m = Mutex.new
+m = Thread::Mutex.new
r = 0
max = 2000
lmax = max * max
diff --git a/benchmark/bm_vm_thread_mutex2.rb b/benchmark/bm_vm_thread_mutex2.rb
index 10de590..6e6c804 100644
--- a/benchmark/bm_vm_thread_mutex2.rb
+++ b/benchmark/bm_vm_thread_mutex2.rb
@@ -1,7 +1,7 @@
# two threads, one mutex
require 'thread'
-m = Mutex.new
+m = Thread::Mutex.new
r = 0
max = 2000
lmax = (max * max)/2
diff --git a/benchmark/bm_vm_thread_mutex3.rb b/benchmark/bm_vm_thread_mutex3.rb
index 7f9a44b..c750dc5 100644
--- a/benchmark/bm_vm_thread_mutex3.rb
+++ b/benchmark/bm_vm_thread_mutex3.rb
@@ -1,7 +1,7 @@
# 1000 threads, one mutex
require 'thread'
-m = Mutex.new
+m = Thread::Mutex.new
r = 0
max = 2000
(1..max).map{
diff --git a/benchmark/bm_vm_thread_queue.rb b/benchmark/bm_vm_thread_queue.rb
index 37381ae..274ceda 100644
--- a/benchmark/bm_vm_thread_queue.rb
+++ b/benchmark/bm_vm_thread_queue.rb
@@ -1,7 +1,7 @@
require 'thread'
n = 1_000_000
-q = Queue.new
+q = Thread::Queue.new
consumer = Thread.new{
while q.pop
# consuming
diff --git a/bootstraptest/test_objectspace.rb b/bootstraptest/test_objectspace.rb
index 862a94e..24a1a0c 100644
--- a/bootstraptest/test_objectspace.rb
+++ b/bootstraptest/test_objectspace.rb
@@ -35,7 +35,7 @@ assert_normal_exit %q{
assert_normal_exit %q{
ObjectSpace.define_finalizer("") do
- Mutex.new.lock
+ Thread::Mutex.new.lock
end
}, '[ruby-dev:44049]'
diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb
index 747b6b8..d16295d 100644
--- a/bootstraptest/test_thread.rb
+++ b/bootstraptest/test_thread.rb
@@ -347,7 +347,7 @@ assert_equal 'ok', %q{
assert_equal 'ok', %q{
begin
- m1, m2 = Mutex.new, Mutex.new
+ m1, m2 = Thread::Mutex.new, Thread::Mutex.new
f1 = f2 = false
Thread.new { m1.lock; f2 = true; sleep 0.001 until f1; m2.lock }
m2.lock; f1 = true; sleep 0.001 until f2; m1.lock
@@ -358,32 +358,32 @@ assert_equal 'ok', %q{
}
assert_equal 'ok', %q{
- m = Mutex.new
+ m = Thread::Mutex.new
Thread.new { m.lock }; sleep 0.1; m.lock
:ok
}
assert_equal 'ok', %q{
- m = Mutex.new
+ m = Thread::Mutex.new
Thread.new { m.lock }; m.lock
:ok
}
assert_equal 'ok', %q{
- m = Mutex.new
+ m = Thread::Mutex.new
Thread.new { m.lock }.join; m.lock
:ok
}
assert_equal 'ok', %q{
- m = Mutex.new
+ m = Thread::Mutex.new
Thread.new { m.lock; sleep 0.2 }
sleep 0.1; m.lock
:ok
}
assert_equal 'ok', %q{
- m = Mutex.new
+ m = Thread::Mutex.new
Thread.new { m.lock; sleep 0.2; m.unlock }
sleep 0.1; m.lock
:ok
@@ -409,7 +409,7 @@ assert_equal 'ok', %{
open("zzz.rb", "w") do |f|
f.puts <<-'end;' # do
begin
- m = Mutex.new
+ m = Thread::Mutex.new
parent = Thread.current
th1 = Thread.new { m.lock; sleep }
sleep 0.01 until th1.stop?
@@ -437,8 +437,8 @@ assert_equal 'ok', %{
assert_finish 3, %q{
require 'thread'
- lock = Mutex.new
- cond = ConditionVariable.new
+ lock = Thread::Mutex.new
+ cond = Thread::ConditionVariable.new
t = Thread.new do
lock.synchronize do
cond.wait(lock)
diff --git a/ext/digest/lib/digest.rb b/ext/digest/lib/digest.rb
index d6daf36..ba0637a 100644
--- a/ext/digest/lib/digest.rb
+++ b/ext/digest/lib/digest.rb
@@ -3,7 +3,7 @@ require 'digest.so'
module Digest
# A mutex for Digest().
- REQUIRE_MUTEX = Mutex.new
+ REQUIRE_MUTEX = Thread::Mutex.new
def self.const_missing(name) # :nodoc:
case name
diff --git a/lib/debug.rb b/lib/debug.rb
index 5d754d8..394a53e 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -182,7 +182,7 @@ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__ # :nodoc:
# Debug is not available in safe mode.
class DEBUGGER__
- MUTEX = Mutex.new # :nodoc:
+ MUTEX = Thread::Mutex.new # :nodoc:
class Context # :nodoc:
DEBUG_LAST_CMD = []
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
index f00e72c..38cb385 100644
--- a/lib/drb/drb.rb
+++ b/lib/drb/drb.rb
@@ -1205,7 +1205,7 @@ module DRb
# not normally need to deal with it directly.
class DRbConn
POOL_SIZE = 16 # :nodoc:
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
@pool = []
def self.open(remote_uri) # :nodoc:
@@ -1824,7 +1824,7 @@ module DRb
end
module_function :install_acl
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
def mutex # :nodoc:
@mutex
end
diff --git a/lib/drb/extservm.rb b/lib/drb/extservm.rb
index e2637aa..7e70a3c 100644
--- a/lib/drb/extservm.rb
+++ b/lib/drb/extservm.rb
@@ -28,7 +28,7 @@ module DRb
@cond = new_cond
@servers = {}
@waiting = []
- @queue = Queue.new
+ @queue = Thread::Queue.new
@thread = invoke_thread
@uri = nil
end
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index ac3e369..16f714d 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -41,7 +41,7 @@ EOF
unless defined? BINDING_QUEUE
require "thread"
- IRB.const_set(:BINDING_QUEUE, SizedQueue.new(1))
+ IRB.const_set(:BINDING_QUEUE, Thread::SizedQueue.new(1))
Thread.abort_on_exception = true
Thread.start do
eval "require \"irb/ws-for-case-2\"", TOPLEVEL_BINDING, __FILE__, __LINE__
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 73741f8..3ded0b3 100644
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -153,7 +153,7 @@ module MonitorMixin
def initialize(monitor)
@monitor = monitor
- @cond = ::ConditionVariable.new
+ @cond = Thread::ConditionVariable.new
end
end
@@ -241,7 +241,7 @@ module MonitorMixin
def mon_initialize
@mon_owner = nil
@mon_count = 0
- @mon_mutex = Mutex.new
+ @mon_mutex = Thread::Mutex.new
end
def mon_check_owner
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
index 6273551..a8472f1 100644
--- a/lib/mutex_m.rb
+++ b/lib/mutex_m.rb
@@ -102,7 +102,7 @@ module Mutex_m
private
def mu_initialize # :nodoc:
- @_mutex = Mutex.new
+ @_mutex = Thread::Mutex.new
end
def initialize(*args) # :nodoc:
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 66a919e..87153ed 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -128,7 +128,7 @@ class PStore
@abort = false
@ultra_safe = false
@thread_safe = thread_safe
- @lock = Mutex.new
+ @lock = Thread::Mutex.new
end
# Raises PStore::Error if the calling code is not in a PStore#transaction.
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 9a981b9..ca4c758 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -180,7 +180,7 @@ class Resolv
def initialize(filename = DefaultFileName)
@filename = filename
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
@initialized = nil
end
@@ -334,7 +334,7 @@ class Resolv
# :ndots => 1)
def initialize(config_info=nil)
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
@config = Config.new(config_info)
@initialized = nil
end
@@ -625,7 +625,7 @@ class Resolv
end
RequestID = {} # :nodoc:
- RequestIDMutex = Mutex.new # :nodoc:
+ RequestIDMutex = Thread::Mutex.new # :nodoc:
def self.allocate_request_id(host, port) # :nodoc:
id = nil
@@ -910,7 +910,7 @@ class Resolv
class Config # :nodoc:
def initialize(config_info=nil)
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
@config_info = config_info
@initialized = nil
@timeouts = nil
diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb
index 9ec8a2f..9b3f13e 100644
--- a/lib/rinda/ring.rb
+++ b/lib/rinda/ring.rb
@@ -385,7 +385,7 @@ module Rinda
# TupleSpaces can be found by calling +to_a+.
def lookup_ring_any(timeout=5)
- queue = Queue.new
+ queue = Thread::Queue.new
Thread.new do
self.lookup_ring(timeout) do |ts|
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
index e29bd63..3ce8d29 100644
--- a/lib/rinda/tuplespace.rb
+++ b/lib/rinda/tuplespace.rb
@@ -246,7 +246,7 @@ module Rinda
def initialize(place, event, tuple, expires=nil)
ary = [event, Rinda::Template.new(tuple)]
super(ary, expires)
- @queue = Queue.new
+ @queue = Thread::Queue.new
@done = false
end
diff --git a/lib/shell.rb b/lib/shell.rb
index 8216eb2..b0bdc81 100644
--- a/lib/shell.rb
+++ b/lib/shell.rb
@@ -12,8 +12,6 @@
require "e2mmap"
-require "thread" unless defined?(Mutex)
-
require "forwardable"
require "shell/error"
@@ -100,7 +98,7 @@ class Shell
@debug_display_process_id = false
@debug_display_thread_id = true
- @debug_output_mutex = Mutex.new
+ @debug_output_mutex = Thread::Mutex.new
class << Shell
extend Forwardable
diff --git a/lib/shell/process-controller.rb b/lib/shell/process-controller.rb
index a100727..a536ebd 100644
--- a/lib/shell/process-controller.rb
+++ b/lib/shell/process-controller.rb
@@ -18,11 +18,11 @@ class Shell
class ProcessController
@ProcessControllers = {}
- @ProcessControllersMonitor = Mutex.new
- @ProcessControllersCV = ConditionVariable.new
+ @ProcessControllersMonitor = Thread::Mutex.new
+ @ProcessControllersCV = Thread::ConditionVariable.new
- @BlockOutputMonitor = Mutex.new
- @BlockOutputCV = ConditionVariable.new
+ @BlockOutputMonitor = Thread::Mutex.new
+ @BlockOutputCV = Thread::ConditionVariable.new
class << self
extend Forwardable
@@ -97,8 +97,8 @@ class Shell
@active_jobs = []
@jobs_sync = Sync.new
- @job_monitor = Mutex.new
- @job_condition = ConditionVariable.new
+ @job_monitor = Thread::Mutex.new
+ @job_condition = Thread::ConditionVariable.new
end
attr_reader :shell
@@ -238,8 +238,8 @@ class Shell
pid = nil
- pid_mutex = Mutex.new
- pid_cv = ConditionVariable.new
+ pid_mutex = Thread::Mutex.new
+ pid_cv = Thread::ConditionVariable.new
Thread.start do
ProcessController.block_output_synchronize do
diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb
index 2a8ffd6e..81456e7 100644
--- a/lib/shell/system-command.rb
+++ b/lib/shell/system-command.rb
@@ -22,7 +22,7 @@ class Shell
@command = command
@opts = opts
- @input_queue = Queue.new
+ @input_queue = Thread::Queue.new
@pid = nil
sh.process_controller.add_schedule(self)
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 2ee9b5b..deb0f52 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -133,7 +133,7 @@ module Singleton
def __init__(klass) # :nodoc:
klass.instance_eval {
@singleton__instance__ = nil
- @singleton__mutex__ = Mutex.new
+ @singleton__mutex__ = Thread::Mutex.new
}
def klass.instance # :nodoc:
return @singleton__instance__ if @singleton__instance__
diff --git a/lib/sync.rb b/lib/sync.rb
index ad6caf0..c953435 100644
--- a/lib/sync.rb
+++ b/lib/sync.rb
@@ -261,7 +261,7 @@ module Sync_m
@sync_ex_locker = nil
@sync_ex_count = 0
- @sync_mutex = Mutex.new
+ @sync_mutex = Thread::Mutex.new
end
def initialize(*args)
diff --git a/lib/thwait.rb b/lib/thwait.rb
index db7e6b1..239915b 100644
--- a/lib/thwait.rb
+++ b/lib/thwait.rb
@@ -51,7 +51,7 @@ class ThreadsWait
#
def initialize(*threads)
@threads = []
- @wait_queue = Queue.new
+ @wait_queue = Thread::Queue.new
join_nowait(*threads) unless threads.empty?
end
diff --git a/lib/tracer.rb b/lib/tracer.rb
index fd45f00..24a5313 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -91,7 +91,7 @@ class Tracer
Tracer::display_thread_id = true
Tracer::display_c_call = false
- @stdout_mutex = Mutex.new
+ @stdout_mutex = Thread::Mutex.new
# Symbol table used for displaying trace information
EVENT_SYMBOL = {
diff --git a/lib/webrick/httpauth/digestauth.rb b/lib/webrick/httpauth/digestauth.rb
index 98bdbd1..375ec20 100644
--- a/lib/webrick/httpauth/digestauth.rb
+++ b/lib/webrick/httpauth/digestauth.rb
@@ -111,7 +111,7 @@ module WEBrick
@instance_key = hexdigest(self.__id__, Time.now.to_i, Process.pid)
@opaques = {}
@last_nonce_expire = Time.now
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
end
##
diff --git a/lib/webrick/httpauth/htdigest.rb b/lib/webrick/httpauth/htdigest.rb
index 4bb25e1..1ef4fdb 100644
--- a/lib/webrick/httpauth/htdigest.rb
+++ b/lib/webrick/httpauth/htdigest.rb
@@ -38,7 +38,7 @@ module WEBrick
@path = path
@mtime = Time.at(0)
@digest = Hash.new
- @mutex = Mutex::new
+ @mutex = Thread::Mutex::new
@auth_type = DigestAuth
open(@path,"a").close unless File::exist?(@path)
reload
diff --git a/lib/webrick/server.rb b/lib/webrick/server.rb
index e2e99bf..45bd970 100644
--- a/lib/webrick/server.rb
+++ b/lib/webrick/server.rb
@@ -98,7 +98,7 @@ module WEBrick
@config[:Logger] ||= Log::new
@logger = @config[:Logger]
- @tokens = SizedQueue.new(@config[:MaxClients])
+ @tokens = Thread::SizedQueue.new(@config[:MaxClients])
@config[:MaxClients].times{ @tokens.push(nil) }
webrickv = WEBrick::VERSION
diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb
index 846829b..eb3b907 100644
--- a/lib/webrick/utils.rb
+++ b/lib/webrick/utils.rb
@@ -126,7 +126,7 @@ module WEBrick
##
# Mutex used to synchronize access across threads
- TimeoutMutex = Mutex.new # :nodoc:
+ TimeoutMutex = Thread::Mutex.new # :nodoc:
##
# Registers a new timeout handler
@@ -154,7 +154,7 @@ module WEBrick
TimeoutMutex.synchronize{
@timeout_info = Hash.new
}
- @queue = Queue.new
+ @queue = Thread::Queue.new
@watcher = nil
end
diff --git a/prelude.rb b/prelude.rb
index 80f178d..f9bb745 100644
--- a/prelude.rb
+++ b/prelude.rb
@@ -1,5 +1,6 @@
class Thread
- MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:
+ MUTEX_FOR_THREAD_EXCLUSIVE = Thread::Mutex.new # :nodoc:
+ private_constant :MUTEX_FOR_THREAD_EXCLUSIVE
# call-seq:
# Thread.exclusive { block } => obj
@@ -8,7 +9,7 @@ class Thread
# value of the block. A thread executing inside the exclusive section will
# only block other threads which also use the Thread.exclusive mechanism.
def self.exclusive
- warn "Thread.exclusive is deprecated, use Mutex", caller
+ warn "Thread.exclusive is deprecated, use Thread::Mutex", caller
MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
yield
}
diff --git a/sample/drb/dhasen.rb b/sample/drb/dhasen.rb
index 651b9c6..9ab8534 100644
--- a/sample/drb/dhasen.rb
+++ b/sample/drb/dhasen.rb
@@ -23,7 +23,7 @@ class Dhasen
include DRbUndumped
def initialize
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
end
def sparse(str, *arg)
diff --git a/sample/drb/dlogd.rb b/sample/drb/dlogd.rb
index 42f302e..be36451 100644
--- a/sample/drb/dlogd.rb
+++ b/sample/drb/dlogd.rb
@@ -10,7 +10,7 @@ class Logger
def initialize(fname)
@fname = fname.to_s
@fp = File.open(@fname, "a+")
- @queue = Queue.new
+ @queue = Thread::Queue.new
@th = Thread.new { self.flush }
end
diff --git a/sample/drb/dqueue.rb b/sample/drb/dqueue.rb
index 1c8878c..1a405f5 100644
--- a/sample/drb/dqueue.rb
+++ b/sample/drb/dqueue.rb
@@ -6,7 +6,7 @@
require 'thread'
require 'drb/drb'
-DRb.start_service(nil, Queue.new)
+DRb.start_service(nil, Thread::Queue.new)
puts DRb.uri
DRb.thread.join
diff --git a/sample/drb/http0serv.rb b/sample/drb/http0serv.rb
index 9503a17..049f5a1 100644
--- a/sample/drb/http0serv.rb
+++ b/sample/drb/http0serv.rb
@@ -18,7 +18,7 @@ module DRb
def initialize(config, drb)
@config = config
@drb = drb
- @queue = Queue.new
+ @queue = Thread::Queue.new
end
def do_POST(req, res)
@@ -46,7 +46,7 @@ module DRb
def initialize(uri, config)
@uri = uri
@config = config
- @queue = Queue.new
+ @queue = Thread::Queue.new
setup_webrick(uri)
end
attr_reader :uri
diff --git a/sample/drb/name.rb b/sample/drb/name.rb
index 9527d47..30c902b 100644
--- a/sample/drb/name.rb
+++ b/sample/drb/name.rb
@@ -75,7 +75,7 @@ class Seq
def initialize(v, name)
@counter = v
- @mutex = Mutex.new
+ @mutex = Thread::Mutex.new
self.drb_name = name
end
@@ -90,7 +90,7 @@ end
class Front
def initialize
seq = Seq.new(0, 'seq')
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
mutex.extend(DRbUndumped)
mutex.extend(DRbNamedObject)
mutex.drb_name = 'mutex'
diff --git a/sample/philos.rb b/sample/philos.rb
index 5c8f43c..622e58b 100644
--- a/sample/philos.rb
+++ b/sample/philos.rb
@@ -8,7 +8,7 @@ srand
N=9 # number of philosophers
$forks = []
for i in 0..N-1
- $forks[i] = Mutex.new
+ $forks[i] = Thread::Mutex.new
end
$state = "-o"*N
diff --git a/test/lib/minitest/unit.rb b/test/lib/minitest/unit.rb
index aa53ef0..b71e8b8 100644
--- a/test/lib/minitest/unit.rb
+++ b/test/lib/minitest/unit.rb
@@ -1008,7 +1008,7 @@ module MiniTest
@report = []
@errors = @failures = @skips = 0
@verbose = false
- @mutex = defined?(Mutex) ? Mutex.new : nil
+ @mutex = Thread::Mutex.new
@info_signal = Signal.list['INFO']
end
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb
index 66c3e83..a386173 100644
--- a/test/monitor/test_monitor.rb
+++ b/test/monitor/test_monitor.rb
@@ -5,6 +5,8 @@ require "thread"
require "test/unit"
class TestMonitor < Test::Unit::TestCase
+ Queue = Thread::Queue
+
def setup
@monitor = Monitor.new
end
diff --git a/test/ruby/lbtest.rb b/test/ruby/lbtest.rb
index 591656a..208c8b2 100644
--- a/test/ruby/lbtest.rb
+++ b/test/ruby/lbtest.rb
@@ -3,8 +3,8 @@ require 'thread'
class LocalBarrier
def initialize(n)
- @wait = Queue.new
- @done = Queue.new
+ @wait = Thread::Queue.new
+ @done = Thread::Queue.new
@keeper = begin_keeper(n)
end
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb
index b6b0f73..ec6e058 100644
--- a/test/ruby/test_backtrace.rb
+++ b/test/ruby/test_backtrace.rb
@@ -228,7 +228,7 @@ class TestBacktrace < Test::Unit::TestCase
def test_thread_backtrace
begin
- q = Queue.new
+ q = Thread::Queue.new
th = Thread.new{
th_rec q
}
@@ -256,7 +256,7 @@ class TestBacktrace < Test::Unit::TestCase
def test_thread_backtrace_locations_with_range
begin
- q = Queue.new
+ q = Thread::Queue.new
th = Thread.new{
th_rec q
}
diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb
index f5a00f9..bd0e502 100644
--- a/test/ruby/test_file.rb
+++ b/test/ruby/test_file.rb
@@ -121,8 +121,8 @@ class TestFile < Test::Unit::TestCase
def test_truncate_size
Tempfile.create("test-truncate") do |f|
- q1 = Queue.new
- q2 = Queue.new
+ q1 = Thread::Queue.new
+ q2 = Thread::Queue.new
th = Thread.new do
data = ''
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 6cbfdb1..4853c41 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -1119,7 +1119,7 @@ class TestRegexp < Test::Unit::TestCase
end
def test_once_multithread
- m = Mutex.new
+ m = Thread::Mutex.new
pr3 = proc{|i|
/#{m.unlock; sleep 0.5; i}/o
}
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index d1390d2..9cb6a43 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -96,7 +96,7 @@ class TestThread < Test::Unit::TestCase
end
def test_mutex_synchronize
- m = Mutex.new
+ m = Thread::Mutex.new
r = 0
num_threads = 10
loop=100
@@ -120,7 +120,7 @@ class TestThread < Test::Unit::TestCase
def test_mutex_synchronize_yields_no_block_params
bug8097 = '[ruby-core:53424] [Bug #8097]'
- assert_empty(Mutex.new.synchronize {|*params| break params}, bug8097)
+ assert_empty(Thread::Mutex.new.synchronize {|*params| break params}, bug8097)
end
def test_local_barrier
@@ -346,8 +346,8 @@ class TestThread < Test::Unit::TestCase
def test_report_on_exception
assert_separately([], <<~"end;") #do
- q1 = Queue.new
- q2 = Queue.new
+ q1 = Thread::Queue.new
+ q2 = Thread::Queue.new
assert_equal(false, Thread.report_on_exception,
"global flags is false by default")
@@ -513,7 +513,7 @@ class TestThread < Test::Unit::TestCase
end
def test_mutex_deadlock
- m = Mutex.new
+ m = Thread::Mutex.new
m.synchronize do
assert_raise(ThreadError) do
m.synchronize do
@@ -524,7 +524,7 @@ class TestThread < Test::Unit::TestCase
end
def test_mutex_interrupt
- m = Mutex.new
+ m = Thread::Mutex.new
m.lock
t = Thread.new do
m.lock
@@ -536,7 +536,7 @@ class TestThread < Test::Unit::TestCase
end
def test_mutex_illegal_unlock
- m = Mutex.new
+ m = Thread::Mutex.new
m.lock
assert_raise(ThreadError) do
Thread.new do
@@ -546,8 +546,8 @@ class TestThread < Test::Unit::TestCase
end
def test_mutex_fifo_like_lock
- m1 = Mutex.new
- m2 = Mutex.new
+ m1 = Thread::Mutex.new
+ m2 = Thread::Mutex.new
m1.lock
m2.lock
m1.unlock
@@ -555,7 +555,7 @@ class TestThread < Test::Unit::TestCase
assert_equal(false, m1.locked?)
assert_equal(false, m2.locked?)
- m3 = Mutex.new
+ m3 = Thread::Mutex.new
m1.lock
m2.lock
m3.lock
@@ -568,7 +568,7 @@ class TestThread < Test::Unit::TestCase
end
def test_mutex_trylock
- m = Mutex.new
+ m = Thread::Mutex.new
assert_equal(true, m.try_lock)
assert_equal(false, m.try_lock, '[ruby-core:20943]')
@@ -753,7 +753,7 @@ class TestThread < Test::Unit::TestCase
end
def test_handle_interrupted?
- q = Queue.new
+ q = Thread::Queue.new
Thread.handle_interrupt(RuntimeError => :never){
done = false
th = Thread.new{
@@ -902,7 +902,7 @@ _eom
def test_main_thread_status_at_exit
assert_in_out_err([], <<-'INPUT', ["false false aborting"], [])
require 'thread'
-q = Queue.new
+q = Thread::Queue.new
Thread.new(Thread.current) {|mth|
begin
q.push nil
@@ -969,7 +969,7 @@ q.pop
end
def test_mutex_owned
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
assert_equal(mutex.owned?, false)
mutex.synchronize {
@@ -981,7 +981,7 @@ q.pop
def test_mutex_owned2
begin
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
th = Thread.new {
# lock forever
mutex.lock
@@ -998,7 +998,7 @@ q.pop
def test_mutex_unlock_on_trap
assert_in_out_err([], <<-INPUT, %w(locked unlocked false), [])
- m = Mutex.new
+ m = Thread::Mutex.new
trapped = false
Signal.trap("INT") { |signo|
@@ -1063,7 +1063,7 @@ q.pop
def test_blocking_mutex_unlocked_on_fork
bug8433 = '[ruby-core:55102] [Bug #8433]'
- mutex = Mutex.new
+ mutex = Thread::Mutex.new
flag = false
mutex.lock
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index c7d4487..5a2ad42 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -411,7 +411,7 @@ class TestTime < Test::Unit::TestCase
end
def test_time_interval
- m = Mutex.new.lock
+ m = Thread::Mutex.new.lock
assert_nothing_raised {
Timeout.timeout(10) {
m.sleep(0)
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 3fe7fb3..7edb5e5 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -142,7 +142,7 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
r1, w = IO.pipe
s1, s2 = UNIXSocket.pair
s1.nonblock = s2.nonblock = true
- lock = Mutex.new
+ lock = Thread::Mutex.new
nr = 0
x = 2
y = 1000
diff --git a/test/test_mutex_m.rb b/test/test_mutex_m.rb
index e31c086..0365265 100644
--- a/test/test_mutex_m.rb
+++ b/test/test_mutex_m.rb
@@ -8,7 +8,7 @@ class TestMutexM < Test::Unit::TestCase
o = Object.new
o.instance_variable_set(:@foo, nil)
o.extend(Mutex_m)
- c = ConditionVariable.new
+ c = Thread::ConditionVariable.new
t = Thread.start {
o.synchronize do
until foo = o.instance_variable_get(:@foo)
diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb
index 815c243..8147d93 100644
--- a/test/test_tempfile.rb
+++ b/test/test_tempfile.rb
@@ -246,8 +246,8 @@ puts Tempfile.new('foo').path
def test_concurrency
threads = []
tempfiles = []
- lock = Mutex.new
- cond = ConditionVariable.new
+ lock = Thread::Mutex.new
+ cond = Thread::ConditionVariable.new
start = false
4.times do
diff --git a/test/test_timeout.rb b/test/test_timeout.rb
index 94ae83e..1af61b7 100644
--- a/test/test_timeout.rb
+++ b/test/test_timeout.rb
@@ -5,7 +5,7 @@ require 'thread'
class TestTimeout < Test::Unit::TestCase
def test_queue
- q = Queue.new
+ q = Thread::Queue.new
assert_raise(Timeout::Error, "[ruby-dev:32935]") {
Timeout.timeout(0.01) { q.pop }
}
diff --git a/test/thread/test_cv.rb b/test/thread/test_cv.rb
index 51afb0b..6779cb3 100644
--- a/test/thread/test_cv.rb
+++ b/test/thread/test_cv.rb
@@ -4,6 +4,9 @@ require 'thread'
require 'tmpdir'
class TestConditionVariable < Test::Unit::TestCase
+ ConditionVariable = Thread::ConditionVariable
+ Mutex = Thread::Mutex
+
def test_initialized
assert_raise(TypeError) {
ConditionVariable.allocate.wait(nil)
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index d2ab683..cadc8e4 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -5,6 +5,9 @@ require 'tmpdir'
require 'timeout'
class TestQueue < Test::Unit::TestCase
+ Queue = Thread::Queue
+ SizedQueue = Thread::SizedQueue
+
def test_queue_initialized
assert_raise(TypeError) {
Queue.allocate.push(nil)