diff options
-rw-r--r-- | ChangeLog-98a | 10 | ||||
-rw-r--r-- | ace/Synch.cpp | 64 | ||||
-rw-r--r-- | ace/Synch.h | 64 | ||||
-rw-r--r-- | ace/Synch.i | 118 |
4 files changed, 189 insertions, 67 deletions
diff --git a/ChangeLog-98a b/ChangeLog-98a index f2054e6a6d3..8843b6b9956 100644 --- a/ChangeLog-98a +++ b/ChangeLog-98a @@ -1,3 +1,13 @@ +Sat Nov 29 13:12:47 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Synch: Conditionally inlined all the ACE_Process_Mutex + wrapper calls and moved them into the Synch.i file. I'm not + sure why there weren't here before. + + * ace/Synch: Reimplemented ACE_RW_Process_Mutex to use + ACE_File_Lock, which provides the proper readers/writer + semantics that had been lacking in the previous implementation. + Fri Nov 28 04:25:23 1997 Nanbor Wang <nw1@merengue.cs.wustl.edu> * ace: Removed redundant trailing commas from diff --git a/ace/Synch.cpp b/ace/Synch.cpp index 15149f96fb6..c53fe7dec4c 100644 --- a/ace/Synch.cpp +++ b/ace/Synch.cpp @@ -82,64 +82,14 @@ ACE_Process_Mutex::~ACE_Process_Mutex (void) delete this->lock_; } -// Explicitly destroy the mutex. -int -ACE_Process_Mutex::remove (void) -{ - return this->lock_->remove (); -} - -// Acquire lock ownership (wait on priority queue if necessary). -int -ACE_Process_Mutex::acquire (void) -{ - return this->lock_->acquire (); -} - -// Conditionally acquire lock (i.e., don't wait on queue). -int -ACE_Process_Mutex::tryacquire (void) -{ - return this->lock_->tryacquire (); -} - -// Release lock and unblock a thread at head of priority queue. -int -ACE_Process_Mutex::release (void) -{ - return this->lock_->release (); -} - -// Acquire lock ownership (wait on priority queue if necessary). -int -ACE_Process_Mutex::acquire_read (void) -{ - return this->lock_->acquire_read (); -} - -// Acquire lock ownership (wait on priority queue if necessary). -int ACE_Process_Mutex::acquire_write (void) -{ - return this->lock_->acquire_write (); -} - -// Conditionally acquire a lock (i.e., won't block). -int -ACE_Process_Mutex::tryacquire_read (void) -{ - return this->lock_->tryacquire_read (); -} - -// Conditionally acquire a lock (i.e., won't block). -int -ACE_Process_Mutex::tryacquire_write (void) +ACE_RW_Process_Mutex::ACE_RW_Process_Mutex (LPCTSTR name, + void *arg) + : lock_ (name, arg) { - return this->lock_->tryacquire_write (); +// ACE_TRACE ("ACE_RW_Process_Mutex::ACE_RW_Process_Mutex"); } -ACE_RW_Process_Mutex::ACE_RW_Process_Mutex (LPCTSTR name, - void *arg) - : ACE_Process_Mutex (name, arg) +ACE_RW_Process_Mutex::~ACE_RW_Process_Mutex (void) { // ACE_TRACE ("ACE_RW_Process_Mutex::ACE_RW_Process_Mutex"); } @@ -148,7 +98,9 @@ void ACE_RW_Process_Mutex::dump (void) const { // ACE_TRACE ("ACE_RW_Process_Mutex::dump"); - ACE_Process_Mutex::dump (); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->lock_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } void diff --git a/ace/Synch.h b/ace/Synch.h index c0bf03dcc1f..1d6c8144b09 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -424,7 +424,7 @@ public: // Explicitly destroy the mutex. int acquire (void); - // Acquire lock ownership (wait on priority queue if necessary). + // Acquire lock ownership (wait on queue if necessary). int tryacquire (void); // Conditionally acquire lock (i.e., don't wait on queue). Returns @@ -432,7 +432,7 @@ public: // the lock, <errno> is set to <EBUSY>. int release (void); - // Release lock and unblock a thread at head of priority queue. + // Release lock and unblock a thread at head of queue. int acquire_read (void); // Acquire mutex ownership. This calls <acquire> and is only @@ -479,8 +479,9 @@ private: class ACE_Export ACE_Process_Mutex // = TITLE - // ACE_Mutex wrapper (valid in same process, as well as across - // processes). + // A wrapper for mutexes that can be used across processes on + // the same host machine, as well as within a process, of + // course. { public: ACE_Process_Mutex (LPCTSTR name = 0, @@ -493,7 +494,7 @@ public: // Explicitly destroy the mutex. int acquire (void); - // Acquire lock ownership (wait on priority queue if necessary). + // Acquire lock ownership (wait on queue if necessary). int tryacquire (void); // Conditionally acquire lock (i.e., don't wait on queue). Returns @@ -501,13 +502,13 @@ public: // the lock, <errno> is set to <EBUSY>. int release (void); - // Release lock and unblock a thread at head of priority queue. + // Release lock and unblock a thread at head of queue. int acquire_read (void); - // Acquire lock ownership (wait on priority queue if necessary). + // Acquire lock ownership (wait on queue if necessary). int acquire_write (void); - // Acquire lock ownership (wait on priority queue if necessary). + // Acquire lock ownership (wait on queue if necessary). int tryacquire_read (void); // Conditionally acquire a lock (i.e., won't block). Returns -1 on @@ -544,13 +545,54 @@ class ACE_Export ACE_RW_Process_Mutex : public ACE_Process_Mutex { public: ACE_RW_Process_Mutex (LPCTSTR name = 0, - void *arg = 0); + void *arg = 0); + // Create a readers/writer <Process_Mutex>, passing in the optional + // <name>. + + ~ACE_RW_Process_Mutex (void); + + int remove (void); + // Explicitly destroy the mutex. + + 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_File_Lock &lock (void) const; + // Return the underlying lock. void dump (void) const; // Dump the state of an object. ACE_ALLOC_HOOK_DECLARE; // Declare the dynamic allocation hooks. + +private: + ACE_File_Lock lock_; + // We need this to get the readers/writer semantics... }; class ACE_Null_Barrier @@ -848,7 +890,7 @@ public: // Explicitly destroy the mutex. int acquire (void); - // Acquire lock ownership (wait on priority queue if necessary). + // Acquire lock ownership (wait on queue if necessary). int tryacquire (void); // Conditionally acquire lock (i.e., don't wait on queue). Returns @@ -856,7 +898,7 @@ public: // the lock, <errno> is set to <EBUSY>. int release (void); - // Release lock and unblock a thread at head of priority queue. + // Release lock and unblock a thread at head of queue. int acquire_read (void); // Acquire mutex ownership. This calls <acquire> and is only here diff --git a/ace/Synch.i b/ace/Synch.i index d76ba3a6932..50381619d9f 100644 --- a/ace/Synch.i +++ b/ace/Synch.i @@ -554,3 +554,121 @@ ACE_Recursive_Thread_Mutex::tryacquire_write (void) #endif /* ACE_HAS_THREADS */ +// Explicitly destroy the mutex. +ACE_INLINE int +ACE_Process_Mutex::remove (void) +{ + return this->lock_->remove (); +} + +// Acquire lock ownership (wait on priority queue if necessary). +ACE_INLINE int +ACE_Process_Mutex::acquire (void) +{ + return this->lock_->acquire (); +} + +// Conditionally acquire lock (i.e., don't wait on queue). +ACE_INLINE int +ACE_Process_Mutex::tryacquire (void) +{ + return this->lock_->tryacquire (); +} + +// Release lock and unblock a thread at head of priority queue. +ACE_INLINE int +ACE_Process_Mutex::release (void) +{ + return this->lock_->release (); +} + +// Acquire lock ownership (wait on priority queue if necessary). +ACE_INLINE int +ACE_Process_Mutex::acquire_read (void) +{ + return this->lock_->acquire_read (); +} + +// Acquire lock ownership (wait on priority queue if necessary). +ACE_INLINE int +ACE_Process_Mutex::acquire_write (void) +{ + return this->lock_->acquire_write (); +} + +// Conditionally acquire a lock (i.e., won't block). +ACE_INLINE int +ACE_Process_Mutex::tryacquire_read (void) +{ + return this->lock_->tryacquire_read (); +} + +// Conditionally acquire a lock (i.e., won't block). +ACE_INLINE int +ACE_Process_Mutex::tryacquire_write (void) +{ + return this->lock_->tryacquire_write (); +} + +// Explicitly destroy the mutex. +ACE_INLINE int +ACE_RW_Process_Mutex::remove (void) +{ + return this->lock_.remove (); +} + +// Acquire lock ownership (wait on priority queue if necessary). +ACE_INLINE int +ACE_RW_Process_Mutex::acquire (void) +{ + return this->lock_.acquire (); +} + +// Conditionally acquire lock (i.e., don't wait on queue). +ACE_INLINE int +ACE_RW_Process_Mutex::tryacquire (void) +{ + return this->lock_.tryacquire (); +} + +// Release lock and unblock a thread at head of priority queue. +ACE_INLINE int +ACE_RW_Process_Mutex::release (void) +{ + return this->lock_.release (); +} + +// Acquire lock ownership (wait on priority queue if necessary). +ACE_INLINE int +ACE_RW_Process_Mutex::acquire_read (void) +{ + return this->lock_.acquire_read (); +} + +// Acquire lock ownership (wait on priority queue if necessary). +ACE_INLINE int +ACE_RW_Process_Mutex::acquire_write (void) +{ + return this->lock_.acquire_write (); +} + +// Conditionally acquire a lock (i.e., won't block). +ACE_INLINE int +ACE_RW_Process_Mutex::tryacquire_read (void) +{ + return this->lock_.tryacquire_read (); +} + +// Conditionally acquire a lock (i.e., won't block). +ACE_INLINE int +ACE_RW_Process_Mutex::tryacquire_write (void) +{ + return this->lock_.tryacquire_write (); +} + +ACE_INLINE const ACE_File_Lock & +ACE_RW_Process_Mutex::lock (void) const +{ +// ACE_TRACE ("ACE_RW_Process_Mutex::lock"); + return this->lock_; +} |