Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
Public Types | Public Member Functions | List of all members
hazelcast::client::Future< V > Class Template Reference

This is a unique Future. More...

#include <Future.h>

Public Types

typedef std::auto_ptr
< serialization::pimpl::Data >(* 
Decoder )(protocol::ClientMessage &response)
 

Public Member Functions

 Future (connection::CallFuture &callFuture, serialization::pimpl::SerializationService &serializationService, Decoder decoder)
 This constructor is only for internal use!!!!
 
 Future (const Future &movedFuture)
 This is actually a move constructor Constructs a Future with the shared state of movedFuture using move semantics. More...
 
Futureoperator= (const Future &movedFuture)
 Assigns the contents of another future object. More...
 
std::auto_ptr< V > get ()
 The get method waits until the future has a valid result and retrieves it. More...
 
future_status wait_for (int64_t timeoutInMilliseconds) const
 Waits for the result to become available. More...
 
void wait () const
 Blocks until the result becomes available. More...
 
bool valid () const
 Checks if the future refers to a shared state. More...
 

Detailed Description

template<typename V>
class hazelcast::client::Future< V >

This is a unique Future.

It can not be shared. The copy constructor actually moves and invalidates the moved from Future. It acts similar to std::future (avaialable since C++11)

This class in NOT THREAD SAFE. DO NOT use concurrently from multiple threads

Constructor & Destructor Documentation

template<typename V >
hazelcast::client::Future< V >::Future ( const Future< V > &  movedFuture)
inline

This is actually a move constructor Constructs a Future with the shared state of movedFuture using move semantics.

After construction, movedFuture.valid() == false.

Member Function Documentation

template<typename V >
std::auto_ptr<V> hazelcast::client::Future< V >::get ( )
inline

The get method waits until the future has a valid result and retrieves it.

It effectively calls wait() in order to wait for the result.

Important Note: get moves the result at the first call and hence it should not be called more than one time. The second call will result in undefined behaviour.

The behaviour is undefined if valid() is false before the call to this function (Our implementation throws FutureUninitialized). Any shared state is released. valid() is false after a call to this method.

Returns
The returned value.
Exceptions
oneof the hazelcast exceptions, if an exception was stored in the shared state referenced by the future
template<typename V >
Future& hazelcast::client::Future< V >::operator= ( const Future< V > &  movedFuture)
inline

Assigns the contents of another future object.

1) Releases any shared state and move-assigns the contents of movedFuture to *this. After the assignment, movedFuture.valid() == false and this->valid() will yield the same value as movedFuture.valid() before the assignment.

template<typename V >
bool hazelcast::client::Future< V >::valid ( ) const
inline

Checks if the future refers to a shared state.

This is the case only for futures that were not moved from until the first time get() is called.

Returns
true if *this refers to a shared state, otherwise false.
template<typename V >
void hazelcast::client::Future< V >::wait ( ) const
inline

Blocks until the result becomes available.

valid() == true after the call.

The behaviour is undefined if valid()== false before the call to this function (Our implementation throws FutureUninitialized).

template<typename V >
future_status hazelcast::client::Future< V >::wait_for ( int64_t  timeoutInMilliseconds) const
inline

Waits for the result to become available.

Blocks until specified timeout_duration has elapsed or the result becomes available, whichever comes first. Returns value identifies the state of the result. A steady clock is used to measure the duration. This function may block for longer than timeout_duration due to scheduling or resource contention delays.

The behaviour is undefined if valid()== false before the call to this function (Our implementation throws FutureUninitialized).

Parameters
timeoutInMillisecondsmaximum duration in milliseconds to block for

The documentation for this class was generated from the following file: