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:

[legend]
List of all members.

## Public Methods
| ACE_Future (void)
| Constructor. More...
| ACE_Future (const ACE_Future< T > &r)
| Copy constructor binds this and r to the same ACE_Future_Rep. An ACE_Future_Rep is created if necessary. More...
| ACE_Future (const T &r)
| Constructor that initialises an ACE_Future to point to the result r immediately. More...
| ~ACE_Future (void)
| Destructor. More...
void | operator= (const ACE_Future< T > &r)
| Assignment operator that binds this and r to the same ACE_Future_Rep. An ACE_Future_Rep is created if necessary. More...
int | cancel (const T &r)
| Cancel an ACE_Future and assign the value r. It is used if a client does not want to wait for the value to be produced. More...
int | cancel (void)
| Cancel an ACE_Future. More...
int | operator== (const ACE_Future< T > &r) const
| Equality operator that returns 1 if both ACE_Future objects point to the same ACE_Future_Rep object. More...
int | operator!= (const ACE_Future< T > &r) const
| Inequality operator, which is the opposite of equality. More...
int | set (const T &r)
| Make the result available. More...
int | get (T &value, ACE_Time_Value *tv=0) const
| Wait to get the object's value. More...
| operator T ()
int | ready (void) const
| Check if the result is available. More...
int | attach (ACE_Future_Observer< T > *observer)
| Attaches the specified observer to a subject (this ACE_Future). More...
int | detach (ACE_Future_Observer< T > *observer)
| Detaches the specified observer from a subject (this ACE_Future). More...
void | dump (void) const
| Dump the state of an object. More...
ACE_Future_Rep< T > * | get_rep (void)
| Get the underlying ACE_Future_Rep pointer. More...
## Public Attributes
| ACE_ALLOC_HOOK_DECLARE
| Declare the dynamic allocation hooks. More...
## Private Types
typedef ACE_Future_Rep< T > | FUTURE_REP
| Protect operations on the <Future>. More...
## Private Methods
void * | operator new (size_t nbytes)
| Do not allow new operator. More...
void | operator delete (void *)
| Do not allow delete operator. More...
void | operator & ()
| Do not allow address-of operator. More...
## Private Attributes
FUTURE_REP * | future_rep_

## Detailed Description

### template<class T>
class ACE_Future< T >

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

## Member Typedef Documentation

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

| Protect operations on the <Future>.

## Constructor & Destructor Documentation

template<class T>
ACE_Future< T >::ACE_Future | ( | void |  | ) |

| Constructor.

template<class T>
ACE_Future< T >::ACE_Future | ( | const ACE_Future< T > & | r | ) |

| Copy constructor binds this and r to the same ACE_Future_Rep. An ACE_Future_Rep is created if necessary.

template<class T>
ACE_Future< T >::ACE_Future | ( | const T & | r | ) |

| Constructor that initialises an ACE_Future to point to the result r immediately.

template<class T>
ACE_Future< T >::~ACE_Future | ( | void |  | ) |

| Destructor.

## Member Function Documentation

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

  | Attaches the specified observer to a subject (this ACE_Future). The update method of the specified subject will be invoked with a copy of the associated ACE_Future 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. Return values:
  0 | Success.
  1 | The observer was already attached.
  -1 | Error; check ACE_OS::last_error() for an error code.

template<class T>
int ACE_Future< T >::cancel | ( | void |  | ) |

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

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

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

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

  | Detaches the specified observer from a subject (this ACE_Future). The update method of the specified subject will not be invoked when the ACE_Future_Rep result gets set. Return values:
  0 | The observer was successfully detached.
  -1 | Error, including the observer not attached prior to calling this method.

template<class T>
void ACE_Future< T >::dump | ( | void |  | ) | const

| Dump the state of an object.

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

  | Wait to get the object's value. value Receives the value of this ACE_Future when it is set. tv Pointer to an ACE_Time_Value containing the absolute time to wait until for the value to be set. If tv is 0, the call waits indefinitely for the value to be set, unless an error occurs. Return values:
  0 | Success; value contains the value of the ACE_Future.
  -1 | Error; check ACE_OS::last_error() for an error code.

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

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

template<class T>
void ACE_Future< T >::operator & | ( |  | ) | `[private]`

| Do not allow address-of operator.

template<class T>
void ACE_Future< T >::operator delete | ( | void * |  | ) | `[private]`

| Do not allow delete operator.

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

| Do not allow new operator.

template<class T>
ACE_Future< T >::operator T | ( |  | ) |

| Deprecated: 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...). Type conversion, which obtains the result of the asynchronous method invocation. Will block forever. The get() method should be used instead since it separates the error value from the result, and also permits timeouts.

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

| Inequality operator, which is the opposite of equality.

template<class T>
void ACE_Future< T >::operator= | ( | const ACE_Future< T > & | rhs | ) |

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

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

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

template<class T>
int ACE_Future< T >::ready | ( | void |  | ) | const

| Check if the result is available.

template<class T>
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<class T>
ACE_Future::ACE_ALLOC_HOOK_DECLARE

| Declare the dynamic allocation hooks.

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

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

- Future.h
- Future.cpp