NAME
ACE_Process_Mutex -
A wrapper for mutexes that can be used across processes on
the same host machine, as well as within a process, of
course.
SYNOPSIS
#include <ace/Synch.h>
class ACE_Process_Mutex
{
public:
ACE_Process_Mutex (LPCTSTR name = 0, void *arg = 0);
~ACE_Process_Mutex (void);
int remove (void);
int acquire (void);
int tryacquire (void);
int release (void);
int acquire_read (void);
int acquire_write (void);
int tryacquire_read (void);
int tryacquire_write (void);
const ACE_mutex_t &lock (void) const;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
ACE_Mutex lock_;
TCHAR name_[ACE_UNIQUE_NAME_LEN];
LPCTSTR unique_name (void);
ACE_SV_Semaphore_Complex lock_;
};
DESCRIPTION
Wrappers for various synchronization routines.
PUBLIC MEMBERS
ACE_Process_Mutex (LPCTSTR name = 0, void *arg = 0);
Create a Process_Mutex, passing in the optional name.
~ACE_Process_Mutex (void);
int remove (void);
Explicitly destroy the mutex. Note that only one thread should
call this method since it doesn't protect against race
conditions.
int acquire (void);
Acquire lock ownership (wait on queue if necessary).
int tryacquire (void);
Conditionally acquire lock (i.e., don't wait on queue). Returns
-1 on failure. If we "failed" because someone else already had
the lock, errno is set to EBUSY.
int release (void);
Release lock and unblock a thread at head of queue.
int acquire_read (void);
Acquire lock ownership (wait on queue if necessary).
int acquire_write (void);
Acquire lock ownership (wait on queue if necessary).
int tryacquire_read (void);
Conditionally acquire a lock (i.e., won't block). Returns -1 on
failure. If we "failed" because someone else already had the
lock, errno is set to EBUSY.
int tryacquire_write (void);
Conditionally acquire a lock (i.e., won't block). Returns -1 on
failure. If we "failed" because someone else already had the
lock, errno is set to EBUSY.
const ACE_mutex_t &lock (void) const;
Return the underlying mutex.
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
PRIVATE MEMBERS
ACE_Mutex lock_;
TCHAR name_[ACE_UNIQUE_NAME_LEN];
If the user does not provide a name we generate a unique name in
this buffer.
LPCTSTR unique_name (void);
Create and return the unique name.
ACE_SV_Semaphore_Complex lock_;
We need this to get the right semantics...
AUTHOR
Doug Schmidt
LIBRARY
ace