2007-08-25 05:09:08 +04:00
|
|
|
class Thread
|
2010-04-11 02:09:09 +04:00
|
|
|
MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:
|
2010-03-29 16:48:43 +04:00
|
|
|
|
|
|
|
# call-seq:
|
|
|
|
# Thread.exclusive { block } => obj
|
2011-05-15 15:55:52 +04:00
|
|
|
#
|
2010-03-29 16:48:43 +04:00
|
|
|
# Wraps a block in Thread.critical, restoring the original value
|
|
|
|
# upon exit from the critical section, and returns the value of the
|
|
|
|
# block.
|
2007-08-25 05:09:08 +04:00
|
|
|
def self.exclusive
|
|
|
|
MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
|
|
|
|
yield
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|