ruby-changes:43964
From: nobu <ko1@a...>
Date: Tue, 30 Aug 2016 15:22:41 +0900 (JST)
Subject: [ruby-changes:43964] nobu:r56037 (trunk): Use qualified names
nobu 2016-08-30 15:22:30 +0900 (Tue, 30 Aug 2016) New Revision: 56037 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56037 Log: Use qualified names Modified files: trunk/benchmark/bm_vm2_mutex.rb trunk/benchmark/bm_vm_thread_mutex1.rb trunk/benchmark/bm_vm_thread_mutex2.rb trunk/benchmark/bm_vm_thread_mutex3.rb trunk/benchmark/bm_vm_thread_queue.rb trunk/bootstraptest/test_objectspace.rb trunk/bootstraptest/test_thread.rb trunk/ext/digest/lib/digest.rb trunk/lib/debug.rb trunk/lib/drb/drb.rb trunk/lib/drb/extservm.rb trunk/lib/irb/workspace.rb trunk/lib/monitor.rb trunk/lib/mutex_m.rb trunk/lib/pstore.rb trunk/lib/resolv.rb trunk/lib/rinda/ring.rb trunk/lib/rinda/tuplespace.rb trunk/lib/shell/process-controller.rb trunk/lib/shell/system-command.rb trunk/lib/shell.rb trunk/lib/singleton.rb trunk/lib/sync.rb trunk/lib/thwait.rb trunk/lib/tracer.rb trunk/lib/webrick/httpauth/digestauth.rb trunk/lib/webrick/httpauth/htdigest.rb trunk/lib/webrick/server.rb trunk/lib/webrick/utils.rb trunk/prelude.rb trunk/sample/drb/dhasen.rb trunk/sample/drb/dlogd.rb trunk/sample/drb/dqueue.rb trunk/sample/drb/http0serv.rb trunk/sample/drb/name.rb trunk/sample/philos.rb trunk/test/lib/minitest/unit.rb trunk/test/monitor/test_monitor.rb trunk/test/ruby/lbtest.rb trunk/test/ruby/test_backtrace.rb trunk/test/ruby/test_file.rb trunk/test/ruby/test_regexp.rb trunk/test/ruby/test_thread.rb trunk/test/ruby/test_time.rb trunk/test/socket/test_unix.rb trunk/test/test_mutex_m.rb trunk/test/test_tempfile.rb trunk/test/test_timeout.rb trunk/test/thread/test_cv.rb trunk/test/thread/test_queue.rb Index: benchmark/bm_vm_thread_mutex2.rb =================================================================== --- benchmark/bm_vm_thread_mutex2.rb (revision 56036) +++ benchmark/bm_vm_thread_mutex2.rb (revision 56037) @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm_thread_mutex2.rb#L1 # two threads, one mutex require 'thread' -m = Mutex.new +m = Thread::Mutex.new r = 0 max = 2000 lmax = (max * max)/2 Index: benchmark/bm_vm2_mutex.rb =================================================================== --- benchmark/bm_vm2_mutex.rb (revision 56036) +++ benchmark/bm_vm2_mutex.rb (revision 56037) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm2_mutex.rb#L1 require 'thread' -m = Mutex.new +m = Thread::Mutex.new i = 0 while i<6_000_000 # benchmark loop 2 Index: benchmark/bm_vm_thread_queue.rb =================================================================== --- benchmark/bm_vm_thread_queue.rb (revision 56036) +++ benchmark/bm_vm_thread_queue.rb (revision 56037) @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm_thread_queue.rb#L1 require 'thread' n = 1_000_000 -q = Queue.new +q = Thread::Queue.new consumer = Thread.new{ while q.pop # consuming Index: benchmark/bm_vm_thread_mutex3.rb =================================================================== --- benchmark/bm_vm_thread_mutex3.rb (revision 56036) +++ benchmark/bm_vm_thread_mutex3.rb (revision 56037) @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm_thread_mutex3.rb#L1 # 1000 threads, one mutex require 'thread' -m = Mutex.new +m = Thread::Mutex.new r = 0 max = 2000 (1..max).map{ Index: benchmark/bm_vm_thread_mutex1.rb =================================================================== --- benchmark/bm_vm_thread_mutex1.rb (revision 56036) +++ benchmark/bm_vm_thread_mutex1.rb (revision 56037) @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_vm_thread_mutex1.rb#L1 # one thread, one mutex (no contention) require 'thread' -m = Mutex.new +m = Thread::Mutex.new r = 0 max = 2000 lmax = max * max Index: prelude.rb =================================================================== --- prelude.rb (revision 56036) +++ prelude.rb (revision 56037) @@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/prelude.rb#L1 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 https://github.com/ruby/ruby/blob/trunk/prelude.rb#L9 # 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 } Index: lib/resolv.rb =================================================================== --- lib/resolv.rb (revision 56036) +++ lib/resolv.rb (revision 56037) @@ -180,7 +180,7 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L180 def initialize(filename = DefaultFileName) @filename = filename - @mutex = Mutex.new + @mutex = Thread::Mutex.new @initialized = nil end @@ -334,7 +334,7 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L334 # :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 https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L625 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 https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L910 class Config # :nodoc: def initialize(config_info=nil) - @mutex = Mutex.new + @mutex = Thread::Mutex.new @config_info = config_info @initialized = nil @timeouts = nil Index: lib/webrick/httpauth/htdigest.rb =================================================================== --- lib/webrick/httpauth/htdigest.rb (revision 56036) +++ lib/webrick/httpauth/htdigest.rb (revision 56037) @@ -38,7 +38,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpauth/htdigest.rb#L38 @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 Index: lib/webrick/httpauth/digestauth.rb =================================================================== --- lib/webrick/httpauth/digestauth.rb (revision 56036) +++ lib/webrick/httpauth/digestauth.rb (revision 56037) @@ -111,7 +111,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/httpauth/digestauth.rb#L111 @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 ## Index: lib/webrick/utils.rb =================================================================== --- lib/webrick/utils.rb (revision 56036) +++ lib/webrick/utils.rb (revision 56037) @@ -126,7 +126,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/utils.rb#L126 ## # 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 https://github.com/ruby/ruby/blob/trunk/lib/webrick/utils.rb#L154 TimeoutMutex.synchronize{ @timeout_info = Hash.new } - @queue = Queue.new + @queue = Thread::Queue.new @watcher = nil end Index: lib/webrick/server.rb =================================================================== --- lib/webrick/server.rb (revision 56036) +++ lib/webrick/server.rb (revision 56037) @@ -98,7 +98,7 @@ module WEBrick https://github.com/ruby/ruby/blob/trunk/lib/webrick/server.rb#L98 @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 Index: lib/debug.rb =================================================================== --- lib/debug.rb (revision 56036) +++ lib/debug.rb (revision 56037) @@ -182,7 +182,7 @@ SCRIPT_LINES__ = {} unless defined? SCRI https://github.com/ruby/ruby/blob/trunk/lib/debug.rb#L182 # Debug is not available in safe mode. class DEBUGGER__ - MUTEX = Mutex.new # :nodoc: + MUTEX = Thread::Mutex.new # :nodoc: class Context # :nodoc: DEBUG_LAST_CMD = [] Index: lib/thwait.rb =================================================================== --- lib/thwait.rb (revision 56036) +++ lib/thwait.rb (revision 56037) @@ -51,7 +51,7 @@ class ThreadsWait https://github.com/ruby/ruby/blob/trunk/lib/thwait.rb#L51 # def initialize(*threads) @threads = [] - @wait_queue = Queue.new + @wait_queue = Thread::Queue.new join_nowait(*threads) unless threads.empty? end Index: lib/irb/workspace.rb =================================================================== --- lib/irb/workspace.rb (revision 56036) +++ lib/irb/workspace.rb (revision 56037) @@ -41,7 +41,7 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/irb/workspace.rb#L41 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__ Index: lib/pstore.rb =================================================================== --- lib/pstore.rb (revision 56036) +++ lib/pstore.rb (revision 56037) @@ -128,7 +128,7 @@ class PStore https://github.com/ruby/ruby/blob/trunk/lib/pstore.rb#L128 @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. Index: lib/mutex_m.rb =================================================================== --- lib/mutex_m.rb (revision 56036) +++ lib/mutex_m.rb (revision 56037) @@ -102,7 +102,7 @@ module Mutex_m https://github.com/ruby/ruby/blob/trunk/lib/mutex_m.rb#L102 private def mu_initialize # :nodoc: - @_mutex = Mutex.new + @_mutex = Thread::Mutex.new end def initialize(*args) # :nodoc: Index: lib/shell/process-controller.rb =================================================================== --- lib/shell/process-controller.rb (revision 56036) +++ lib/shell/process-controller.rb (revision 56037) @@ -18,11 +18,11 @@ class Shell https://github.com/ruby/ruby/blob/trunk/lib/shell/process-controller.rb#L18 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 https://github.com/ruby/ruby/blob/trunk/lib/shell/process-controller.rb#L97 @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 https://github.com/ruby/ruby/blob/trunk/lib/shell/process-controller.rb#L238 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 Index: lib/shell/system-command.rb =================================================================== --- lib/shell/system-command.rb (revision 56036) +++ lib/shell/system-command.rb (revision 56037) @@ -22,7 +22,7 @@ class Shell https://github.com/ruby/ruby/blob/trunk/lib/shell/system-command.rb#L22 @command = command @opts = opts - @input_queue = Queue.new + @input_queue = Thread::Queue.new @pid = nil sh.process_controller.add_schedule(self) Index: lib/shell.rb =================================================================== --- lib/shell.rb (revision 56036) +++ lib/shell.rb (revision 56037) @@ -12,8 +12,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/shell.rb#L12 require "e2mmap" -require "thread" unless defined?(Mutex) - require "forwardable" require "shell/error" @@ -100,7 +98,7 @@ class Shell https://github.com/ruby/ruby/blob/trunk/lib/shell.rb#L98 @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 Index: lib/tracer.rb =================================================================== --- lib/tracer.rb (revision 56036) +++ lib/tracer.rb (revision 56037) @@ -91,7 +91,7 @@ class Tracer https://github.com/ruby/ruby/blob/trunk/lib/tracer.rb#L91 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 = { Index: lib/monitor.rb =================================================================== --- lib/monitor.rb (revision 56036) +++ lib/monitor.rb (revision 56037) @@ -153,7 +153,7 @@ module MonitorMixin https://github.com/ruby/ruby/blob/trunk/lib/monitor.rb#L153 def initialize(monitor) @monitor = monitor - @cond = ::ConditionVariable.new + @cond = Thread::ConditionVariable.new end end @@ -241,7 +241,7 @@ module MonitorMixin https://github.com/ruby/ruby/blob/trunk/lib/monitor.rb#L241 def mon_initialize @mon_owner = nil @mon_count = 0 - @mon_mutex = Mutex.new + @mon_mutex = Thread::Mutex.new end def mon_check_owner Index: lib/rinda/ring.rb =================================================================== --- lib/rinda/ring.rb (revision 56036) +++ lib/rinda/ring.rb (revision 56037) @@ -385,7 +385,7 @@ module Rinda https://github.com/ruby/ruby/blob/trunk/lib/rinda/ring.rb#L385 # 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| Index: lib/rinda/tuplespace.rb =================================================================== --- lib/rinda/tuplespace.rb (revision 56036) +++ lib/rinda/tuplespace.rb (revision 56037) @@ -246,7 +246,7 @@ module Rinda https://github.com/ruby/ruby/blob/trunk/lib/rinda/tuplespace.rb#L246 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 Index: lib/singleton.rb =================================================================== --- lib/singleton.rb (revision 56036) +++ lib/singleton.rb (revision 56037) @@ -133,7 +133,7 @@ module Singleton https://github.com/ruby/ruby/blob/trunk/lib/singleton.rb#L133 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__ Index: lib/drb/drb.rb =================================================================== --- lib/drb/drb.rb (revision 56036) +++ lib/drb/drb.rb (revision 56037) @@ -1205,7 +1205,7 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1205 # 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 https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1824 end module_function :install_acl - @mutex = Mutex.new + @mutex = Thread::Mutex.new def mutex # :nodoc: @mutex end Index: lib/drb/extservm.rb =================================================================== --- lib/drb/extservm.rb (revision 56036) +++ lib/drb/extservm.rb (revision 56037) @@ -28,7 +28,7 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/extservm.rb#L28 @cond = new_cond @servers = {} @waiting = [] - @queue = Queue.new + @queue = Thread::Queue.new @thread = invoke_thread @uri = nil end Index: lib/sync.rb =================================================================== --- lib/sync.rb (revision 56036) +++ lib/sync.rb (revision 56037) @@ -261,7 +261,7 @@ module Sync_m https://github.com/ruby/ruby/blob/trunk/lib/sync.rb#L261 @sync_ex_locker = nil @sync_ex_count = 0 - @sync_mutex = Mutex.new + @sync_mutex = Thread::Mutex.new end def initialize(*args) Index: sample/drb/name.rb =================================================================== --- sample/drb/name.rb (revision 56036) +++ sample/drb/name.rb (revision 56037) @@ -75,7 +75,7 @@ class Seq https://github.com/ruby/ruby/blob/trunk/sample/drb/name.rb#L75 def initialize(v, name) @counter = v - @mutex = Mutex.new + @mutex = Thread::Mutex.new self.drb_name = name end @@ -90,7 +90,7 @@ end https://github.com/ruby/ruby/blob/trunk/sample/drb/name.rb#L90 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' Index: sample/drb/dqueue.rb =================================================================== --- sample/drb/dqueue.rb (revision 56036) +++ sample/drb/dqueue.rb (revision 56037) @@ -6,7 +6,7 @@ https://github.com/ruby/ruby/blob/trunk/sample/drb/dqueue.rb#L6 require 'thread' require 'drb/drb' -DRb.start_service(nil, Queue.new) +DRb.start_service(nil, Thread::Queue.new) puts DRb.uri DRb.thread.join Index: sample/drb/http0serv.rb =================================================================== --- sample/drb/http0serv.rb (revision 56036) +++ sample/drb/http0serv.rb (revision 56037) @@ -18,7 +18,7 @@ module DRb https://github.com/ruby/ruby/blob/trunk/sample/drb/http0serv.rb#L18 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 https://github.com/ruby/ruby/blob/trunk/sample/drb/http0serv.rb#L46 def initialize(uri, config) @uri = uri @config = config - @queue = Queue.new + @queue = Thread::Queue.new setup_webrick(uri) end attr_reader :uri Index: sample/drb/dlogd.rb =================================================================== --- sample/drb/dlogd.rb (revision 56036) +++ sample/drb/dlogd.rb (revision 56037) @@ -10,7 +10,7 @@ class Logger https://github.com/ruby/ruby/blob/trunk/sample/drb/dlogd.rb#L10 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 Index: sample/drb/dhasen.rb =================================================================== --- sample/drb/dhasen.rb (revision 56036) +++ sample/drb/dhasen.rb (revision 56037) @@ -23,7 +23,7 @@ class Dhasen https://github.com/ruby/ruby/blob/trunk/sample/drb/dhasen.rb#L23 include DRbUndumped def initialize - @mutex = Mutex.new + @mutex = Thread::Mutex.new end def sparse(str, *arg) Index: sample/philos.rb =================================================================== --- sample/philos.rb (revision 56036) +++ sample/philos.rb (revision 56037) @@ -8,7 +8,7 @@ srand https://github.com/ruby/ruby/blob/trunk/sample/philos.rb#L8 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 Index: ext/digest/lib/digest.rb =================================================================== --- ext/digest/lib/digest.rb (revision 56036) +++ ext/digest/lib/digest.rb (revision 56037) @@ -3,7 +3,7 @@ require 'digest.so' https://github.com/ruby/ruby/blob/trunk/ext/digest/lib/digest.rb#L3 module Digest # A mutex for Digest(). - REQUIRE_MUTEX = Mutex.new + REQUIRE_MUTEX = Thread::Mutex.new def self.const_missing(name) # :nodoc: case name Index: test/test_mutex_m.rb =================================================================== --- test/test_mutex_m.rb (revision 56036) +++ test/test_mutex_m.rb (revision 56037) @@ -8,7 +8,7 @@ class TestMutexM (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/