2007-08-24 15:26:28 +00:00
|
|
|
|
|
|
|
# Mutex
|
|
|
|
|
|
|
|
class Mutex
|
2007-08-24 18:10:37 +00:00
|
|
|
def synchronize
|
|
|
|
self.lock
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
self.unlock
|
2007-08-24 15:26:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-08-25 01:09:08 +00:00
|
|
|
# Thread
|
|
|
|
|
|
|
|
class Thread
|
|
|
|
MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new
|
|
|
|
def self.exclusive
|
|
|
|
MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
|
|
|
|
yield
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|