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
15 16 17 18 19 20 21 22 23 |
# File 'lib/async/variable.rb', line 15 def resolve(value = true) @value = value condition = @condition @condition = nil self.freeze condition.signal(value) end |
#resolved? ⇒ Boolean
25 26 27 |
# File 'lib/async/variable.rb', line 25 def resolved? @condition.nil? end |
#value ⇒ Object
29 30 31 32 |
# File 'lib/async/variable.rb', line 29 def value @condition&.wait return @value end |
#wait ⇒ Object
34 35 36 |
# File 'lib/async/variable.rb', line 34 def wait self.value end |