class Async::Variable
@deprecated Use {Async::Promise} instead.
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) warn("`Async::Variable` is deprecated, use `Async::Promise` instead.", category: :deprecated, uplevel: 1) if $VERBOSE @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 value
def value self.wait end
def value=(value)
def value=(value) self.resolve(value) end
def wait
Wait for the value to be resolved.
def wait @condition&.wait return @value end