---
name: "ACE_Read_Guard"
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_Read_Guard"
---

# ACE\_Read\_Guard(3)

This class is similar to class ACE\_Guard, though it acquires/releases a read lock automatically (naturally, the ACE\_LOCK it is instantiated with must support the appropriate API).

## NAME

ACE\_Read\_Guard -  This class is similar to class ACE\_Guard, though it acquires/releases a read lock automatically (naturally, the ACE\_LOCK it is instantiated with must support the appropriate API).

## SYNOPSIS

```
#include <ace/Synch_T.h>
template<class ACE_LOCK>
class ACE_Read_Guard : public ACE_Guard<ACE_LOCK>
{
  public:
    ACE_Read_Guard (ACE_LOCK& m);
    ACE_Read_Guard (ACE_LOCK &m, int block);
    int acquire_read (void);
    int acquire (void);
    int tryacquire_read (void);
    int tryacquire (void);
    void dump (void) const;
};
```

## Initialization methods.

```
ACE_Read_Guard (ACE_LOCK& m);
```

Implicitly and automatically acquire a read lock.

```
ACE_Read_Guard (ACE_LOCK &m, int block);
```

Implicitly and automatically acquire (or try to acquire) a read lock.

## Lock accessors.

```
int acquire_read (void);
```

Explicitly acquire the read lock.

```
int acquire (void);
```

Explicitly acquire the read lock.

```
int tryacquire_read (void);
```

Conditionally acquire the read lock (i.e., won't block).

```
int tryacquire (void);
```

Conditionally acquire the read lock (i.e., won't block).

## Utility methods.

```
void dump (void) const;
```

Dump the state of an object.

ACE\_ALLOC\_HOOK\_DECLARE; Declare the dynamic allocation hooks.

## AUTHOR

Doug Schmidt

## LIBRARY

ace
