---
name: "ACE_Recursive_Thread_Mutex"
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_Recursive_Thread_Mutex"
---

# ACE\_Recursive\_Thread\_Mutex(3)

Implement a C++ wrapper that allows nested acquisition and release of a mutex that occurs in the same thread.

## NAME

ACE\_Recursive\_Thread\_Mutex -  Implement a C++ wrapper that allows nested acquisition and release of a mutex that occurs in the same thread.

## SYNOPSIS

```
#include <ace/Synch.h>
class ACE_Recursive_Thread_Mutex
{
  public:
    ACE_Recursive_Thread_Mutex (LPCTSTR name = 0, void *arg = 0);
    ~ACE_Recursive_Thread_Mutex (void);
    int remove (void);
    int acquire (void);
    int tryacquire (void);
    int acquire_read (void);
    int acquire_write (void);
    int tryacquire_read (void);
    int tryacquire_write (void);
    int release (void);
    ACE_thread_t get_thread_id (void);
    int get_nesting_level (void);
    void dump (void) const;
    ACE_ALLOC_HOOK_DECLARE;
  protected:
    void set_thread_id (ACE_thread_t t);
    ACE_recursive_thread_mutex_t recursive_mutex_;
    int removed_;
  private:
    void operator= (const ACE_Recursive_Thread_Mutex &);
    ACE_Recursive_Thread_Mutex (const ACE_Recursive_Thread_Mutex &);
};
```

## DESCRIPTION

Wrappers for various synchronization routines.

## This method should \*not\* be public (they hold no locks...)

```
void set_thread_id (ACE_thread_t t);
```

```
ACE_recursive_thread_mutex_t recursive_mutex_;
```

Recursive mutex.

```
int removed_;
```

Keeps track of whether remove has been called yet to avoid multiple remove calls, e.g., explicitly and implicitly in the destructor.  This flag isn't protected by a lock, so make sure that you don't have multiple threads simultaneously calling remove on the same object, which is a bad idea anyway...

## Prevent assignment and initialization.

```
void operator= (const ACE_Recursive_Thread_Mutex &);
```

```
ACE_Recursive_Thread_Mutex (const ACE_Recursive_Thread_Mutex &);
```

## AUTHOR

Doug Schmidt

## LIBRARY

ace
