Class: Strand::Atc
- Inherits:
-
Object
- Object
- Strand::Atc
- Defined in:
- lib/strand/atc.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Atc
constructor
A new instance of Atc.
- #signal(state) ⇒ Object
-
#wait(state, timeout = nil) ⇒ Object
Wait for state to happen.
Constructor Details
#initialize(options = {}) ⇒ Atc
Returns a new instance of Atc.
4 5 6 7 8 |
# File 'lib/strand/atc.rb', line 4 def initialize( = {}) @timeout = [:timeout] @cond = ConditionVariable.new @states = [] end |
Instance Method Details
#signal(state) ⇒ Object
21 22 23 24 |
# File 'lib/strand/atc.rb', line 21 def signal(state) @states << state @cond.signal end |
#wait(state, timeout = nil) ⇒ Object
Wait for state to happen.
11 12 13 14 15 16 17 18 19 |
# File 'lib/strand/atc.rb', line 11 def wait(state, timeout = nil) return true if @states.include?(state) timeout ||= @timeout if timeout wait_with_timeout(state, timeout) else wait_without_timeout(state) end end |