diff options
Diffstat (limited to 'ace/Process_Mutex.h')
-rw-r--r-- | ace/Process_Mutex.h | 112 |
1 files changed, 61 insertions, 51 deletions
diff --git a/ace/Process_Mutex.h b/ace/Process_Mutex.h index 241c7375370..dc8f0f08c62 100644 --- a/ace/Process_Mutex.h +++ b/ace/Process_Mutex.h @@ -1,23 +1,20 @@ /* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Process_Mutex.h -// -// = DESCRIPTION -// A wrapper for mutexes that can be used across processes on -// the same host machine, as well as within a process, of -// course. -// -// = AUTHOR -// Doug Schmidt -// -// ============================================================================ + +//============================================================================= +/** + * @file Process_Mutex.h + * + * $Id$ + * + * A wrapper for mutexes that can be used across processes on + * the same host machine, as well as within a process, of + * course. + * + * + * @author Doug Schmidt + */ +//============================================================================= + #ifndef ACE_PROCESS_MUTEX_H #define ACE_PROCESS_MUTEX_H @@ -35,86 +32,99 @@ #include "ace/Synch.h" #endif /* !(ACE_WIN32 || ACE_HAS_POSIX_SEM || ACE_PSOS) */ +/** + * @class ACE_Process_Mutex + * + * @brief A wrapper for mutexes that can be used across processes on + * the same host machine, as well as within a process, of + * course. + */ class ACE_Export ACE_Process_Mutex { - // = TITLE - // A wrapper for mutexes that can be used across processes on - // the same host machine, as well as within a process, of - // course. public: + /// Create a Process_Mutex, passing in the optional <name>. ACE_Process_Mutex (const char *name = 0, void *arg = 0); - // Create a Process_Mutex, passing in the optional <name>. #if defined (ACE_HAS_WCHAR) + /// Create a Process_Mutex, passing in the optional <name>. (wchar_t version) ACE_Process_Mutex (const wchar_t *name, void *arg = 0); - // Create a Process_Mutex, passing in the optional <name>. (wchar_t version) #endif /* ACE_HAS_WCHAR */ ~ACE_Process_Mutex (void); + /** + * Explicitly destroy the mutex. Note that only one thread should + * call this method since it doesn't protect against race + * conditions. + */ int remove (void); - // Explicitly destroy the mutex. Note that only one thread should - // call this method since it doesn't protect against race - // conditions. + /// Acquire lock ownership (wait on queue if necessary). int acquire (void); - // Acquire lock ownership (wait on queue if necessary). + /** + * 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 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>. + /// Release lock and unblock a thread at head of queue. int release (void); - // Release lock and unblock a thread at head of queue. + /// Acquire lock ownership (wait on queue if necessary). int acquire_read (void); - // Acquire lock ownership (wait on queue if necessary). + /// Acquire lock ownership (wait on queue if necessary). int acquire_write (void); - // Acquire lock ownership (wait on queue if necessary). + /** + * 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_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>. + /** + * 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>. + /** + * This is only here for consistency with the other synchronization + * APIs and usability with Lock adapters. Assumes the caller already has + * acquired the mutex and returns 0 in all cases. + */ int tryacquire_write_upgrade (void); - // This is only here for consistency with the other synchronization - // APIs and usability with Lock adapters. Assumes the caller already has - // acquired the mutex and returns 0 in all cases. #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS) + /// Return the underlying mutex. const ACE_mutex_t &lock (void) const; - // Return the underlying mutex. #endif /* ACE_WIN32 || ACE_HAS_POSIX_SEM || ACE_PSOS */ + /// Dump the state of an object. void dump (void) const; - // Dump the state of an object. + /// Declare the dynamic allocation hooks. ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. private: #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS) ACE_Mutex lock_; #else + /// If the user does not provide a name we generate a unique name in + /// this buffer. ACE_TCHAR name_[ACE_UNIQUE_NAME_LEN]; - // If the user does not provide a name we generate a unique name in - // this buffer. + /// Create and return the unique name. const ACE_TCHAR *unique_name (void); - // Create and return the unique name. + /// We need this to get the right semantics... ACE_SV_Semaphore_Complex lock_; - // We need this to get the right semantics... #endif /* ACE_WIN32 || ACE_HAS_POSIX_SEM || ACE_PSOS */ }; |