class Cassandra::Future
A Future represents a result of asynchronous execution. It can be used to block until a value is available or an error has happened, or register a listener to be notified whenever the execution is complete.
Inherits
Object
Classes
Methods
value
(value)Returns a future resolved to a given value
error
(error)Returns a future resolved to a given error
all
(*futures)Returns a future that resolves with values of all futures
on_success
{|value| … }Run block when future resolves to a value
- Note
- The block can be called synchronously from current thread if the future has already been resolved, or, asynchronously, from background thread upon resolution.
join
Block until the future has been resolved
- Note
- This method blocks until a future is resolved
- Note
- This method won’t raise any errors or return anything but the future itself
get
Returns future value or raises future error
- Note
- This method blocks until a future is resolved
on_failure
{|error| … }Run block when future resolves to error
- Note
- The block can be called synchronously from current thread if the future has already been resolved, or, asynchronously, from background thread upon resolution.
on_complete
{|value, error| … }Run block when future resolves. The block will always be called with 2 arguments - value and error. In case a future resolves to an error, the error argument will be non-nil.
- Note
- The block can be called synchronously from current thread if the future has already been resolved, or, asynchronously, from background thread upon resolution.
add_listener
(listener)Add future listener
- Note
- The listener can be notified synchronously, from current thread, if the future has already been resolved, or, asynchronously, from background thread upon resolution.
- Note
- that provided listener doesn’t have to extend
Listener
, only conform to the same interface
then
{|value| … }Returns a new future that will resolve to the result of the block. Besides regular values, block can return other futures, which will be transparently unwrapped before resolving the future from this method.
- Note
- The block can be called synchronously from current thread if the future has already been resolved, or, asynchronously, from background thread upon resolution.
fallback
{|error| … }Returns a new future that will resolve to the result of the block in case of an error. Besides regular values, block can return other futures, which will be transparently unwrapped before resolving the future from this method.
- Note
- The block can be called synchronously from current thread if the future has already been resolved, or, asynchronously, from background thread upon resolution.