## NAME

ACE_Future_Rep - ACE_Future_Rep`T`

## SYNOPSIS

    #include <ace/Future.h>

    template<class T>
    class ACE_Future_Rep
    {
      private:
        friend class ACE_Future<T>;
        int set (const T &r, ACE_Future<T> &caller);
        int get (T &value, ACE_Time_Value *tv);
        int attach (
            ACE_Future_Observer<T> *observer,
            ACE_Future<T> &caller
            );
        int detach (ACE_Future_Observer<T> *observer);
        operator T ();
        void dump (void) const;
        ACE_ALLOC_HOOK_DECLARE;
        static ACE_Future_Rep<T> *create (void);
        static ACE_Future_Rep<T> *attach (ACE_Future_Rep<T> *&rep);
        static void detach (ACE_Future_Rep<T> *&rep);
        static void assign (
            ACE_Future_Rep<T> *&rep,
            ACE_Future_Rep<T> *new_rep
            );
        int ready (void);
        T *value_;
        int ref_count_;
        typedef ACE_Future_Observer<T> OBSERVER;
        typedef ACE_Unbounded_Set<OBSERVER *> OBSERVER_COLLECTION;
        OBSERVER_COLLECTION observer_collection_;
        ACE_Condition_Thread_Mutex value_ready_;
        ACE_Thread_Mutex value_ready_mutex_;
        ACE_Future_Rep (void);
        ~ACE_Future_Rep (void);
    };

## DESCRIPTION

An ACE_Future_Rep`T` object encapsules a pointer to an object of class T which is the result of an asynchronous method invocation. It is pointed to by ACE_Future`T` object[s] and only accessible through them.

## Encapsulate reference count and object lifetime of instances.

These methods must go after the others to work around a bug with Borland's C++ Builder...

    static ACE_Future_Rep<T> *create (void);

Create a ACE_Future_Rep`T` and initialize the reference count.

    static ACE_Future_Rep<T> *attach (ACE_Future_Rep<T> *&rep);

Increase the reference count and return argument. Uses the attribute "value_ready_mutex_" to synchronize reference count updating.

Precondition (rep != 0).

    static void detach (ACE_Future_Rep<T> *&rep);

Decreases the reference count and and deletes rep if there are no more references to rep.

Precondition (rep != 0)

    static void assign (
        ACE_Future_Rep<T> *&rep,
        ACE_Future_Rep<T> *new_rep
        );

Decreases the rep's reference count and and deletes rep if there are no more references to rep. Then assigns new_rep to rep.

Precondition (rep != 0 && new_rep != 0)

    int ready (void);

Is result available?

    T *value_;

Pointer to the result.

    int ref_count_;

Reference count.

    typedef ACE_Future_Observer<T> OBSERVER;

    typedef ACE_Unbounded_Set<OBSERVER *> OBSERVER_COLLECTION;

    OBSERVER_COLLECTION observer_collection_;

Keep a list of ACE_Future_Observers unread by client's reader thread.

= Condition variable and mutex that protect the `value_`.

    ACE_Condition_Thread_Mutex value_ready_;

    ACE_Thread_Mutex value_ready_mutex_;

## Constructor and destructor private.

    ACE_Future_Rep (void);

    ~ACE_Future_Rep (void);

## AUTHOR (S)

Andres Kruse `Andres.Kruse@cern.ch`, Douglas C. Schmidt `schmidt@cs.wustl.edu`, Per Andersson `Per.Andersson@hfera.ericsson.se`, and John Tucker `jtucker@infoglide.com`

## LIBRARY

ace