class Async::Variable
A synchronization primitive that allows one task to wait for another task to resolve a value.
def initialize(condition = Condition.new)
Create a new variable.
def initialize(condition = Condition.new) @condition = condition @value = nil end
def resolve(value = true)
Signals all waiting tasks.
Resolve the value.
def resolve(value = true) @value = value condition = @condition @condition = nil self.freeze condition.signal(value) end
def resolved?
Whether the value has been resolved.
def resolved? @condition.nil? end
def wait
Wait for the value to be resolved.
def wait @condition&.wait return @value end