diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-11-01 22:17:39 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-11-01 22:17:39 +0000 |
commit | 4cdff4b3e2dbc73b00e671ef638d71d6d854e0ac (patch) | |
tree | 97236ece363cff48fd287c780db4290da39b02cb /ace/Process_Semaphore.h | |
parent | 7b6368ec78831d127f38eb7b630c21f98faf6a83 (diff) | |
download | ATCD-4cdff4b3e2dbc73b00e671ef638d71d6d854e0ac.tar.gz |
ChangeLogTag:Wed Nov 1 14:11:48 2000 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'ace/Process_Semaphore.h')
-rw-r--r-- | ace/Process_Semaphore.h | 136 |
1 files changed, 76 insertions, 60 deletions
diff --git a/ace/Process_Semaphore.h b/ace/Process_Semaphore.h index d33107dfa1e..208bafe8dc1 100644 --- a/ace/Process_Semaphore.h +++ b/ace/Process_Semaphore.h @@ -1,22 +1,19 @@ /* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// Process_Semaphore.h -// -// = DESCRIPTION -// Wrapper for Dijkstra style general semaphores that work -// across processes. -// -// = AUTHOR -// Doug Schmidt -// -// ============================================================================ + +//============================================================================= +/** + * @file Process_Semaphore.h + * + * $Id$ + * + * Wrapper for Dijkstra style general semaphores that work + * across processes. + * + * + * @author Doug Schmidt + */ +//============================================================================= + #ifndef ACE_PROCESS_SEMAPHORE_H #define ACE_PROCESS_SEMAPHORE_H @@ -32,89 +29,108 @@ #include "ace/SV_Semaphore_Complex.h" #endif /* !(ACE_WIN32 || ACE_HAS_POSIX_SEM || ACE_PSOS) */ +/** + * @class ACE_Process_Semaphore + * + * @brief Wrapper for Dijkstra style general semaphores that work + * across processes. + */ class ACE_Export ACE_Process_Semaphore { - // = TITLE - // Wrapper for Dijkstra style general semaphores that work - // across processes. public: + /// Initialize the semaphore, with an initial value of <count> and a + /// maximum value of <max>. ACE_Process_Semaphore (u_int count = 1, // By default make this unlocked. const ACE_TCHAR *name = 0, void * = 0, int max = 0x7FFFFFFF); - // Initialize the semaphore, with an initial value of <count> and a - // maximum value of <max>. + /** + * This method is a no-op, i.e., it doesn't remove the semaphore. + * If you want to remove the semaphore, you must call the <remove> + * method explicitly. + */ ~ACE_Process_Semaphore (void); - // This method is a no-op, i.e., it doesn't remove the semaphore. - // If you want to remove the semaphore, you must call the <remove> - // method explicitly. + /** + * Explicitly destroy the semaphore. Note that only one thread + * should call this method since it doesn't protect against race + * conditions. + */ int remove (void); - // Explicitly destroy the semaphore. Note that only one thread - // should call this method since it doesn't protect against race - // conditions. + /// Block the thread until the semaphore count becomes greater than + /// 0, then decrement it. int acquire (void); - // Block the thread until the semaphore count becomes greater than - // 0, then decrement it. + /** + * Conditionally decrement the semaphore if count is greater than 0 + * (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 (void); - // Conditionally decrement the semaphore if count is greater than 0 - // (i.e., won't block). Returns -1 on failure. If we "failed" - // because someone else already had the lock, <errno> is set to - // <EBUSY>. + /// Increment the semaphore, potentially unblocking a waiting thread. int release (void); - // Increment the semaphore, potentially unblocking a waiting thread. + /** + * Acquire semaphore ownership. This calls <acquire> and is only + * here to make the <ACE_Process_Semaphore> interface consistent + * with the other synchronization APIs. + */ int acquire_read (void); - // Acquire semaphore ownership. This calls <acquire> and is only - // here to make the <ACE_Process_Semaphore> interface consistent - // with the other synchronization APIs. + /** + * Acquire semaphore ownership. This calls <acquire> and is only + * here to make the <ACE_Process_Semaphore> interface consistent + * with the other synchronization APIs. + */ int acquire_write (void); - // Acquire semaphore ownership. This calls <acquire> and is only - // here to make the <ACE_Process_Semaphore> interface consistent - // with the other synchronization APIs. + /** + * Conditionally acquire semaphore (i.e., won't block). This calls + * <tryacquire> and is only here to make the <ACE_Process_Semaphore> + * interface consistent with the other synchronization APIs. + * 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 semaphore (i.e., won't block). This calls - // <tryacquire> and is only here to make the <ACE_Process_Semaphore> - // interface consistent with the other synchronization APIs. - // Returns -1 on failure. If we "failed" because someone else - // already had the lock, <errno> is set to <EBUSY>. + /** + * Conditionally acquire semaphore (i.e., won't block). This calls + * <tryacquire> and is only here to make the <ACE_Process_Semaphore> + * interface consistent with the other synchronization APIs. + * 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 semaphore (i.e., won't block). This calls - // <tryacquire> and is only here to make the <ACE_Process_Semaphore> - // interface consistent with the other synchronization APIs. - // Returns -1 on failure. If we "failed" because someone else - // already had the lock, <errno> is set to <EBUSY>. + /** + * This is only here to make the <ACE_Process_Semaphore> + * interface consistent with the other synchronization APIs. + * Assumes the caller has already acquired the semaphore using one of + * the above calls, and returns 0 (success) always. + */ int tryacquire_write_upgrade (void); - // This is only here to make the <ACE_Process_Semaphore> - // interface consistent with the other synchronization APIs. - // Assumes the caller has already acquired the semaphore using one of - // the above calls, and returns 0 (success) always. #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS) + /// Return the underlying lock. const ACE_sema_t &lock (void) const; - // Return the underlying lock. #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. protected: #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS) ACE_Semaphore lock_; #else + /// 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 */ }; |