Class: Async::Variable
- Inherits:
-
Object
- Object
- Async::Variable
- Defined in:
- lib/async/variable.rb
Instance Method Summary collapse
-
#initialize(condition = Condition.new) ⇒ Variable
constructor
A new instance of Variable.
- #resolve(value = true) ⇒ Object
- #resolved? ⇒ Boolean
- #value ⇒ Object
- #wait ⇒ Object
Constructor Details
Instance Method Details
#resolve(value = true) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/async/variable.rb', line 32 def resolve(value = true) @value = value condition = @condition @condition = nil self.freeze condition.signal(value) end |
#resolved? ⇒ Boolean
42 43 44 |
# File 'lib/async/variable.rb', line 42 def resolved? @condition.nil? end |
#value ⇒ Object
46 47 48 49 |
# File 'lib/async/variable.rb', line 46 def value @condition&.wait return @value end |
#wait ⇒ Object
51 52 53 |
# File 'lib/async/variable.rb', line 51 def wait self.value end |