class Concurrent::Promises::ResolvableFuture
A Future which can be resolved by user.
def evaluate_to(*args, &block)
-
(self)
-
Other tags:
- Yieldreturn: - value
Other tags:
- Yield: - to the block.
def evaluate_to(*args, &block) promise.evaluate_to(*args, block) end
def evaluate_to!(*args, &block)
-
(Exception)
- also raise reason on rejection.
Returns:
-
(self)
-
Other tags:
- Yieldreturn: - value
Other tags:
- Yield: - to the block.
def evaluate_to!(*args, &block) promise.evaluate_to(*args, block).wait! end
def fulfill(value, raise_on_reassign = true, reserved = false)
-
value
(Object
) --
def fulfill(value, raise_on_reassign = true, reserved = false) resolve_with Fulfilled.new(value), raise_on_reassign, reserved end
def reason(timeout = nil, timeout_value = nil, resolve_on_timeout = nil)
- See: Future#reason -
Returns:
-
(Exception, timeout_value, nil)
-
def reason(timeout = nil, timeout_value = nil, resolve_on_timeout = nil) if wait_until_resolved timeout internal_state.reason else if resolve_on_timeout unless resolve(*resolve_on_timeout, false) # if it fails to resolve it was resolved in the meantime # so return value as if there was no timeout return internal_state.reason end end timeout_value end end
def reject(reason, raise_on_reassign = true, reserved = false)
-
reason
(Object
) --
def reject(reason, raise_on_reassign = true, reserved = false) resolve_with Rejected.new(reason), raise_on_reassign, reserved end
def resolve(fulfilled = true, value = nil, reason = nil, raise_on_reassign = true, reserved = false)
-
reason
(Object
) -- -
value
(Object
) -- -
fulfilled
(true, false
) --
def resolve(fulfilled = true, value = nil, reason = nil, raise_on_reassign = true, reserved = false) resolve_with(fulfilled ? Fulfilled.new(value) : Rejected.new(reason), raise_on_reassign, reserved) end
def result(timeout = nil, resolve_on_timeout = nil)
- See: Future#result -
Returns:
-
(::Array(Boolean, Object, Exception), nil)
-
def result(timeout = nil, resolve_on_timeout = nil) if wait_until_resolved timeout internal_state.result else if resolve_on_timeout unless resolve(*resolve_on_timeout, false) # if it fails to resolve it was resolved in the meantime # so return value as if there was no timeout internal_state.result end end # otherwise returns nil end end
def value(timeout = nil, timeout_value = nil, resolve_on_timeout = nil)
- See: Future#value -
Returns:
-
(Object, timeout_value, nil)
-
def value(timeout = nil, timeout_value = nil, resolve_on_timeout = nil) if wait_until_resolved timeout internal_state.value else if resolve_on_timeout unless resolve(*resolve_on_timeout, false) # if it fails to resolve it was resolved in the meantime # so return value as if there was no timeout return internal_state.value end end timeout_value end end
def value!(timeout = nil, timeout_value = nil, resolve_on_timeout = nil)
- See: Future#value! -
Raises:
-
(Exception)
- {#reason} on rejection
Returns:
-
(Object, timeout_value, nil)
-
def value!(timeout = nil, timeout_value = nil, resolve_on_timeout = nil) if wait_until_resolved! timeout internal_state.value else if resolve_on_timeout unless resolve(*resolve_on_timeout, false) # if it fails to resolve it was resolved in the meantime # so return value as if there was no timeout raise self if rejected? return internal_state.value end end timeout_value end end
def wait(timeout = nil, resolve_on_timeout = nil)
- See: AbstractEventFuture#wait -
Returns:
-
(self, true, false)
-
def wait(timeout = nil, resolve_on_timeout = nil) super(timeout) or if resolve_on_timeout # if it fails to resolve it was resolved in the meantime # so return true as if there was no timeout !resolve(*resolve_on_timeout, false) else false end end
def wait!(timeout = nil, resolve_on_timeout = nil)
- See: Future#wait! -
Raises:
-
(Exception)
- {#reason} on rejection
Returns:
-
(self, true, false)
-
def wait!(timeout = nil, resolve_on_timeout = nil) super(timeout) or if resolve_on_timeout if resolve(*resolve_on_timeout, false) false else # if it fails to resolve it was resolved in the meantime # so return true as if there was no timeout raise self if rejected? true end else false end end
def with_hidden_resolvable
-
(Future)
-
def with_hidden_resolvable @with_hidden_resolvable ||= FutureWrapperPromise.new_blocked_by1(self, @DefaultExecutor).future end