diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-10 21:32:09 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-10-10 21:32:09 +0000 |
commit | 7eec5a8373208982fc5f20387e35d077538d68b0 (patch) | |
tree | f91651d743234ebbacdf709afd1c1db7f6038f87 | |
parent | bd2bf237bc479cb1d5c0dd99352c8917ef46ea17 (diff) | |
download | ATCD-7eec5a8373208982fc5f20387e35d077538d68b0.tar.gz |
ChangeLogTag:Sat Oct 10 16:28:00 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
-rw-r--r-- | ChangeLog-98b | 13 | ||||
-rw-r--r-- | ace/Synch.cpp | 30 | ||||
-rw-r--r-- | ace/Synch.h | 11 | ||||
-rw-r--r-- | ace/Synch.i | 19 |
4 files changed, 47 insertions, 26 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b index 14def4a0df3..5b5a8cb24c2 100644 --- a/ChangeLog-98b +++ b/ChangeLog-98b @@ -1,3 +1,16 @@ +Sat Oct 10 16:28:00 1998 Carlos O'Ryan <coryan@cs.wustl.edu> + + * ace/Synch.h: + * ace/Synch.i: + * ace/Synch.cpp: + The ACE_Process_Mutex class was allocating one of its members + from the heap, thus it could not be placed in shared memory. + The problem was that the member required the creation of a + unique name if the user did not provide one; making the buffer + for this unique name a member of ACE_Process_Mutex allowed us to + initialize the lock_ member while still allocating it as a + member of the class. + Sat Oct 10 12:45:31 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * ace/Malloc_T.h: Added a documentation entry for class diff --git a/ace/Synch.cpp b/ace/Synch.cpp index a27a1ea9a32..1fd5927c6fa 100644 --- a/ace/Synch.cpp +++ b/ace/Synch.cpp @@ -121,34 +121,36 @@ ACE_Process_Mutex::dump (void) const { // ACE_TRACE ("ACE_Process_Mutex::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - this->lock_->dump (); + this->lock_.dump (); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); } -ACE_Process_Mutex::ACE_Process_Mutex (LPCTSTR name, void *arg) +#if !defined (ACE_WIN32) && !defined (ACE_HAS_POSIX_SEM) +LPCTSTR +ACE_Process_Mutex::unique_name (void) { -#if !defined (ACE_WIN32) // For all platforms other than Win32, we are going to create a // machine wide unquie name if one is not provided by the user. On // Win32, unnamed synchronization objects are acceptable. - TCHAR ace_name[ACE_UNIQUE_NAME_LEN]; - if (name == 0) - { - ACE::unique_name (this, ace_name, ACE_UNIQUE_NAME_LEN); - name = ace_name; - } -#endif + ACE::unique_name (this, this->name_, ACE_UNIQUE_NAME_LEN); + return this->name_; +} +#endif /* !ACE_WIN32 && !ACE_HAS_POSIX_SEM */ + +ACE_Process_Mutex::ACE_Process_Mutex (LPCTSTR name, void *arg) #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) - ACE_NEW (this->lock_, ACE_Mutex (USYNC_PROCESS, name, arg)); + : lock_ (USYNC_PROCESS, name, arg) #else - ACE_UNUSED_ARG (arg); - ACE_NEW (this->lock_, ACE_SV_Semaphore_Complex (name)); + : lock_ (name?name:ACE_Process_Mutex::unique_name ()) #endif /* ACE_WIN32 || ACE_HAS_POSIX_SEM */ +{ +#if !defined (ACE_WIN32) && !defined (ACE_HAS_POSIX_SEM) + ACE_UNUSED_ARG (arg); +#endif /* !ACE_WIN32 && !ACE_HAS_POSIX_SEM */ } ACE_Process_Mutex::~ACE_Process_Mutex (void) { - delete this->lock_; } ACE_RW_Process_Mutex::ACE_RW_Process_Mutex (LPCTSTR name, diff --git a/ace/Synch.h b/ace/Synch.h index e5357594634..5c813276c88 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -575,9 +575,16 @@ public: // Declare the dynamic allocation hooks. #if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) - ACE_Mutex *lock_; + ACE_Mutex lock_; #else - ACE_SV_Semaphore_Complex *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... #endif /* ACE_WIN32 */ }; diff --git a/ace/Synch.i b/ace/Synch.i index a1a623fcaa2..f2b2cedb468 100644 --- a/ace/Synch.i +++ b/ace/Synch.i @@ -306,7 +306,7 @@ ACE_INLINE const ACE_mutex_t & ACE_Process_Mutex::lock (void) const { // ACE_TRACE ("ACE_Process_Mutex::lock"); - return this->lock_->lock (); + return this->lock_.lock (); } ACE_INLINE const ACE_sema_t & @@ -604,8 +604,7 @@ ACE_Recursive_Thread_Mutex::get_nesting_level (void) ACE_INLINE int ACE_Process_Mutex::remove (void) { - int retv = this->lock_->remove (); - this->lock_ = 0; + int retv = this->lock_.remove (); return retv; } @@ -613,49 +612,49 @@ ACE_Process_Mutex::remove (void) ACE_INLINE int ACE_Process_Mutex::acquire (void) { - return this->lock_->acquire (); + 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 (); + 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 (); + 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 (); + 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 (); + 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 (); + 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 (); + return this->lock_.tryacquire_write (); } // Explicitly destroy the mutex. |