2007-08-24 21:09:08 -04:00
|
|
|
class Thread
|
2010-04-10 18:09:09 -04:00
|
|
|
MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:
|
2010-03-29 08:48:43 -04:00
|
|
|
|
|
|
|
# call-seq:
|
|
|
|
# Thread.exclusive { block } => obj
|
2011-05-15 07:55:52 -04:00
|
|
|
#
|
2014-04-17 03:31:43 -04:00
|
|
|
# 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.
|
2007-08-24 21:09:08 -04:00
|
|
|
def self.exclusive
|
|
|
|
MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
|
|
|
|
yield
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|