---
name: "ACE_Test_and_Set"
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_Test_and_Set"
---

# ACE\_Test\_and\_Set(3)

## NAME

ACE\_Test\_and\_Set

## SYNOPSIS

```
#include <ace/Synch_T.h>
template<class ACE_LOCK, class TYPE>
class ACE_Test_and_Set : public ACE_Event_Handler
{
  public:
    ACE_Test_and_Set (TYPE initial_value = 0);
    TYPE is_set (void) const;
    TYPE set (TYPE);
    virtual int handle_signal (
        int signum,
        siginfo_t * = 0,
        ucontext_t * = 0
        );
  private:
    TYPE is_set_;
    ACE_LOCK lock_;
};
```

## TITLE

Implements the classic \`\`test and set'' operation.

## DESCRIPTION

This class keeps track of the status of is\_set\_, which can be set based on various events (such as receipt of a signal).  This class is derived from ACE\_Event\_Handler so that it can be "signaled" by a Reactor when a signal occurs. We assume that TYPE is a data type that can be assigned the value 0 or 1.

```
ACE_Test_and_Set (TYPE initial_value = 0);
```

```
TYPE is_set (void) const;
```

Returns true if we are set, else false.

```
TYPE set (TYPE);
```

Sets the is\_set\_ status, returning the original value of is\_set\_.

```
virtual int handle_signal (
    int signum,
    siginfo_t * = 0,
    ucontext_t * = 0
    );
```

Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled).

## AUTHOR

Doug Schmidt

## LIBRARY

ace
