summaryrefslogtreecommitdiff
path: root/prelude.rb
blob: 8ce306caa292ca62e1dfaea58ca457395e213761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# Mutex

class Mutex
  def synchronize
    self.lock
    yield
  ensure
    self.unlock
  end
end

# Thread

class Thread
  MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new
  def self.exclusive
    MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
      yield
    }
  end
end