struct Syn::Core::Future(T)
- Syn::Core::Future(T)
- Struct
- Value
- Object
Overview
An object that will eventually hold a value.
Can be used to ask an Agent
to compute a value asynchronously, while the
current fiber continues to do other things, yet be able to retrieve or wait
until the value is available.
TODO report a failure (with an optional exception)
Defined in:
core/future.crConstructors
Instance Method Summary
-
#fail(error : Exception | String | Nil = nil) : Nil
Report a failure when trying to resolve the future.
-
#get(timeout : Time::Span) : T | Nil
Blocks the current fiber until the value is resolved or timeout is reached, in which case it returns
nil
. -
#get : T
Blocks the current fiber until the value is resolved.
-
#get? : T | Nil
Returns the value if it was resolved.
-
#set(value : T) : T
Sets the value and wakes up pending fibers.
Constructor Detail
Instance Method Detail
Report a failure when trying to resolve the future. Wakes up pending fibers.
TODO raise if the future has already been resolved
Blocks the current fiber until the value is resolved or timeout is
reached, in which case it returns nil
.
Returns the value if it was resolved. Returns nil
otherwise without
blocking. Raises an exception if the future has failed.
Sets the value and wakes up pending fibers.
TODO raise if the future has already been resolved