blob: cc24a81474ed9987a5e60393722704b43375f0b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Thread
MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new # :nodoc:
# 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
MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
yield
}
end
end
|