1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

prelude.rb: eliminate a private constant

* prelude.rb (Thread.exclusive): eliminate a private constant,
  MUTEX_FOR_THREAD_EXCLUSIVE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-01-07 03:10:00 +00:00
parent 4328d1f50d
commit b9ca126577

View file

@ -1,16 +1,15 @@
class Thread class << Thread
MUTEX_FOR_THREAD_EXCLUSIVE = Thread::Mutex.new # :nodoc:
private_constant :MUTEX_FOR_THREAD_EXCLUSIVE
# call-seq: # call-seq:
# Thread.exclusive { block } => obj # Thread.exclusive { block } => obj
# #
# Wraps the block in a single, VM-global Mutex.synchronize, returning the # Wraps the block in a single, VM-global Mutex.synchronize, returning the
# value of the block. A thread executing inside the exclusive section will # value of the block. A thread executing inside the exclusive section will
# only block other threads which also use the Thread.exclusive mechanism. # only block other threads which also use the Thread.exclusive mechanism.
def self.exclusive(&block) def exclusive(&block) end if false
mutex = Mutex.new # :nodoc:
define_method(:exclusive) do |&block|
warn "Thread.exclusive is deprecated, use Thread::Mutex", caller warn "Thread.exclusive is deprecated, use Thread::Mutex", caller
MUTEX_FOR_THREAD_EXCLUSIVE.synchronize(&block) mutex.synchronize(&block)
end end
end end