NAME
ACE_Recursive_Lock -
Implement a C++ wrapper that allows calls to class ACE_Mutex,
ACE_RW_Mutex, and ACE_Semaphore to be nested for a nested
acquire() that occurs in the same thread.
SYNOPSIS
#include <ace/Synch_T.h>
template<class LOCK>
class ACE_Recursive_Lock
{
public:
ACE_Recursive_Lock (
int type = USYNC_THREAD,
const char *name = 0,
void *arg = 0
);
~ACE_Recursive_Lock (void);
int remove (void);
int acquire (void);
int tryacquire (void);
int release (void);
operator LOCK &();
thread_t get_thread_id (void);
int get_nesting_level (void);
void dump (void) const;
private:
void set_nesting_level (int depth);
void set_thread_id (thread_t t);
LOCK lock_;
LOCK nesting_mutex_;
thread_t thr_id_;
int nesting_level_;
inline void operator= (const ACE_Recursive_Lock<LOCK> &);
inline ACE_Recursive_Lock (const ACE_Recursive_Lock<LOCK> &);
};
These methods should *not* be public since they hold no locks.
void set_nesting_level (int depth);
void set_thread_id (thread_t t);
LOCK lock_;
This is the lock that actually suspends other waiting threads.
LOCK nesting_mutex_;
Guards the state of the nesting level and thread id.
thread_t thr_id_;
Current owner of the lock.
int nesting_level_;
Current nesting level of the recursion. This is a good place to
use the new C++ mutable keyword.
Prevent assignment and initialization.
inline void operator= (const ACE_Recursive_Lock<LOCK> &);
inline ACE_Recursive_Lock (const ACE_Recursive_Lock<LOCK> &);
AUTHOR
Doug Schmidt
LIBRARY
ace