Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Future Class Template Reference

This class implements a ``single write, multiple read'' pattern that can be used to return results from asynchronous method invocations. More...

#include <Future.h>

Collaboration diagram for ACE_Future:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Future (void)
 Constructor.

 ACE_Future (const ACE_Future<T> &r)
 Copy constructor binds <this> and <r> to the same . An is created if necessary.

 ACE_Future (const T &r)
 Constructor that initialises an to point to the result <r> immediately.

 ~ACE_Future (void)
 Destructor.

void operator= (const ACE_Future<T> &r)
 Assignment operator that binds <this> and <r> to the same . An is created if necessary.

int cancel (const T &r)
 Cancel an and assign the value <r>. It is used if a client does not want to wait for <T> to be produced.

int cancel (void)
int operator== (const ACE_Future<T> &r) const
int operator!= (const ACE_Future<T> &r) const
 Inequality operator, which is the opposite of equality.

int set (const T &r)
int get (T &value, ACE_Time_Value *tv = 0)
 Wait up to <tv> time to get the <value>. Note that <tv> must be specified in absolute time rather than relative time.

 operator T ()
int ready (void)
 Check if the result is available.

int attach (ACE_Future_Observer<T> *observer)
int detach (ACE_Future_Observer<T> *observer)
void dump (void) const
 Dump the state of an object.

ACE_Future_Rep<T>* get_rep (void)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Types

typedef ACE_Future_Rep<T> FUTURE_REP
 Protect operations on the <Future>.


Private Methods

void* operator new (size_t nbytes)
 Do not allow new operator.

void operator delete (void *)
 Do not allow delete operator.

void operator & ()
 Do not allow address-of operator.


Private Attributes

FUTURE_REPfuture_rep_

Detailed Description

template<class T> template class ACE_Future

This class implements a ``single write, multiple read'' pattern that can be used to return results from asynchronous method invocations.


Member Typedef Documentation

template<classT>
typedef ACE_Future_Rep<T> ACE_Future<T>::FUTURE_REP [private]
 

Protect operations on the <Future>.


Constructor & Destructor Documentation

template<classT>
ACE_Future<T>::ACE_Future<T> ( void )
 

Constructor.

template<classT>
ACE_Future<T>::ACE_Future<T> ( const ACE_Future< T >& r )
 

Copy constructor binds <this> and <r> to the same . An is created if necessary.

template<classT>
ACE_Future<T>::ACE_Future<T> ( const T & r )
 

Constructor that initialises an to point to the result <r> immediately.

template<classT>
ACE_Future<T>::~ACE_Future<T> ( void )
 

Destructor.


Member Function Documentation

template<classT>
int ACE_Future<T>::attach ( ACE_Future_Observer< T >* observer )
 

Attaches the specified observer to a subject (i.e. the ). The update method of the specified subject will be invoked with a copy of the associated as input when the result gets set. If the result is already set when this method gets invoked, then the update method of the specified subject will be invoked immediately.

Returns 0 if the observer is successfully attached, 1 if the observer is already attached, and -1 if failures occur.

template<classT>
int ACE_Future<T>::cancel ( void )
 

Cancel an . Put the future into its initial state. Returns 0 on succes and -1 on failure. It is now possible to reuse the ACE_Future<T>. But remember, the ACE_Future<T> is now bound to a new ACE_Future_Rep<T>.

template<classT>
int ACE_Future<T>::cancel ( const T & r )
 

Cancel an and assign the value <r>. It is used if a client does not want to wait for <T> to be produced.

template<classT>
int ACE_Future<T>::detach ( ACE_Future_Observer< T >* observer )
 

Detaches the specified observer from a subject (i.e. the ). The update method of the specified subject will not be invoked when the result gets set. Returns 1 if the specified observer was actually attached to the subject prior to this call and 0 if was not.

Returns 0 if the observer was successfully detached, and -1 if the observer was not attached in the first place.

template<classT>
void ACE_Future<T>::dump ( void ) const
 

Dump the state of an object.

template<classT>
int ACE_Future<T>::get ( T & value,
ACE_Time_Value * tv = 0 )
 

Wait up to <tv> time to get the <value>. Note that <tv> must be specified in absolute time rather than relative time.

template<classT>
ACE_Future_Rep< T >* ACE_Future<T>::get_rep ( void )
 

Get the underlying *. Note that this method should rarely, if ever, be used and that modifying the undlerlying * should be done with extreme caution.

template<classT>
void ACE_Future<T>::operator & ( ) [private]
 

Do not allow address-of operator.

template<classT>
ACE_Future<T>::operator T ( )
 

Type conversion, which obtains the result of the asynchronous method invocation. Will block forever. Note that this method is going away in a subsequent release since it doesn't distinguish between failure results and success results (exceptions should be used, but they aren't portable...). The <get> method should be used instead since it separates the error value from the result, and also permits timeouts.

template<classT>
void ACE_Future<T>::operator delete ( void * ) [private]
 

Do not allow delete operator.

template<classT>
void * ACE_Future<T>::operator new ( size_t nbytes ) [private]
 

Do not allow new operator.

template<classT>
int ACE_Future<T>::operator!= ( const ACE_Future< T >& r ) const
 

Inequality operator, which is the opposite of equality.

template<classT>
void ACE_Future<T>::operator= ( const ACE_Future< T >& r )
 

Assignment operator that binds <this> and <r> to the same . An is created if necessary.

template<classT>
int ACE_Future<T>::operator== ( const ACE_Future< T >& r ) const
 

Equality operator that returns 1 if both ACE_Future<T> objects point to the same ACE_Future_Rep<T> object. Attention: It also returns 1 if both objects have just been instantiated and not used yet.

template<classT>
int ACE_Future<T>::ready ( void )
 

Check if the result is available.

template<classT>
int ACE_Future<T>::set ( const T & r )
 

Make the result available. Is used by the server thread to give the result to all waiting clients. Returns 0 for success, -1 on failure. This function only has an effect the first time it is called for the object (actually, the first time the underlying ACE_Future_Rep has a value assigned to it). Subsequent calls return 0 (success) but have no effect.


Member Data Documentation

template<classT>
ACE_Future<T>::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

template<classT>
FUTURE_REP * ACE_Future<T>::future_rep_ [private]
 


The documentation for this class was generated from the following files:
Generated at Sat Dec 1 11:02:01 2001 for ACE by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000