Class: Wakame::Rule::BasicActionSet::Lock
- Inherits:
-
Object
- Object
- Wakame::Rule::BasicActionSet::Lock
- Defined in:
- lib/wakame/rule.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ Lock
constructor
A new instance of Lock.
- #signal ⇒ Object
- #wait(&blk) ⇒ Object
Constructor Details
#initialize ⇒ Lock
Returns a new instance of Lock.
12 13 14 15 |
# File 'lib/wakame/rule.rb', line 12 def initialize @mutex = Mutex.new @cond = ConditionVariable.new end |
Instance Method Details
#signal ⇒ Object
17 18 19 20 21 |
# File 'lib/wakame/rule.rb', line 17 def signal @mutex.synchronize { @cond.signal } end |
#wait(&blk) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wakame/rule.rb', line 23 def wait(&blk) if blk.nil? i=0 blk = proc { i += 1 i > 1 ? true : false } end @mutex.synchronize { @cond.wait(@mutex) while blk.call } end |