---
name: "ACE_Singleton"
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_Singleton"
---

# ACE\_Singleton(3)

A Singleton Adapter uses the Adapter pattern to turn ordinary classes into Singletons optimized with the Double-Checked Locking optimization pattern.

## NAME

ACE\_Singleton -  A Singleton Adapter uses the Adapter pattern to turn ordinary classes into Singletons optimized with the Double-Checked Locking optimization pattern.

## SYNOPSIS

```
#include <ace/Singleton.h>
template<class TYPE, class ACE_LOCK>
class ACE_Singleton : public ACE_Cleanup
{
  public:
    static TYPE *instance (void);
    virtual void cleanup (void *param = 0);
    static void dump (void);
  protected:
    ACE_Singleton (void);
    TYPE instance_;
    static ACE_Singleton<TYPE, ACE_LOCK> *singleton_;
    static ACE_Singleton<TYPE, ACE_LOCK> *&instance_i (void);
};
```

## DESCRIPTION

## PUBLIC MEMBERS

```
static TYPE *instance (void);
```

Global access point to the Singleton.

```
virtual void cleanup (void *param = 0);
```

Cleanup method, used by ace\_cleanup\_destroyer to destroy the ACE\_Singleton.

```
static void dump (void);
```

Dump the state of the object.

## PROTECTED MEMBERS

```
ACE_Singleton (void);
```

Default constructor.

```
TYPE instance_;
```

Contained instance.

```
static ACE_Singleton<TYPE, ACE_LOCK> *singleton_;
```

Pointer to the Singleton (ACE\_Cleanup) instance.

```
static ACE_Singleton<TYPE, ACE_LOCK> *&instance_i (void);
```

Get pointer to the Singleton instance.

## AUTHOR

Tim Harrison (harrison@cs.wustl.edu), Douglas C. Schmidt, Chris Lahey, Rich Christy, and David Levine.

## LIBRARY

ace
