diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-07 03:10:00 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-07 03:10:00 +0000 |
commit | b9ca12657788f0345f7ada886e5de9b199923b59 (patch) | |
tree | 06ef8dc8d6be4898be91e1de92313dc7d8d36921 /prelude.rb | |
parent | 4328d1f50d361ff8bfbf5311e689fb9cc8ca780d (diff) | |
download | ruby-b9ca12657788f0345f7ada886e5de9b199923b59.tar.gz |
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
Diffstat (limited to 'prelude.rb')
-rw-r--r-- | prelude.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/prelude.rb b/prelude.rb index 7cfe0892b3..9e94aadf9c 100644 --- a/prelude.rb +++ b/prelude.rb @@ -1,16 +1,15 @@ -class Thread - MUTEX_FOR_THREAD_EXCLUSIVE = Thread::Mutex.new # :nodoc: - private_constant :MUTEX_FOR_THREAD_EXCLUSIVE - +class << Thread # call-seq: # Thread.exclusive { block } => obj # # Wraps the block in a single, VM-global Mutex.synchronize, returning the # 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(&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 - MUTEX_FOR_THREAD_EXCLUSIVE.synchronize(&block) + mutex.synchronize(&block) end end |