---
name: "ACE_Future_Rep"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_Future_Rep"
---

# ACE\_Future\_Rep(3)

ACE\_Future\_RepT

## NAME

ACE\_Future\_Rep -  ACE\_Future\_RepT

## 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\_RepT 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\_FutureT 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\_RepT 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
