diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-05-11 05:29:33 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-05-11 05:29:33 +0000 |
commit | 48adf6bc4d2cb81c5bd542890ebe8a281510f3ac (patch) | |
tree | ba85bb509e6450faa09da37506a023e6fb2a93fc /ace/Thread_Manager.cpp | |
parent | 431388bf5c64d9d796d126ca81981fe363aeb393 (diff) | |
download | ATCD-48adf6bc4d2cb81c5bd542890ebe8a281510f3ac.tar.gz |
More Thread_Manager optimization.
Diffstat (limited to 'ace/Thread_Manager.cpp')
-rw-r--r-- | ace/Thread_Manager.cpp | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index 92a552a801a..3bedcb3a3c3 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -106,6 +106,25 @@ ACE_Thread_Descriptor::ACE_Thread_Descriptor (void) ACE_NEW (this->sync_, ACE_DEFAULT_THREAD_MANAGER_LOCK); } +void +ACE_Thread_Descriptor::acquire_release (void) +{ + // Just try to acquire the lock then release it. + if (this->registered_ == 0) + { + this->sync_->acquire (); + // Acquire the lock before removing <td> from the thread table. If + // this thread is in the table already, it should simply acquire the + // lock easily. + + // Once we get the lock, we must have registered. + ACE_ASSERT (this->registered_ != 0); + + this->sync_->release (); + // Release the lock before putting it back to freelist. + } +} + // The following macro simplifies subsequence code. #define ACE_FIND(OP,INDEX) \ ACE_Thread_Descriptor *INDEX = OP; \ @@ -348,7 +367,7 @@ ACE_Thread_Exit::thr_mgr (ACE_Thread_Manager *tm) ACE_TRACE ("ACE_Thread_Exit::thr_mgr"); if (tm != 0) - this->thread_control_.insert (tm); + this->thread_control_.insert (tm, 0); } // Set the thread exit status value. @@ -806,20 +825,6 @@ ACE_Thread_Manager::remove_thr (ACE_Thread_Descriptor *td, { ACE_TRACE ("ACE_Thread_Manager::remove_thr"); - if (td->registered_ == 0) - { - td->sync_->acquire (); - // Acquire the lock before removing <td> from the thread table. If - // this thread is in the table already, it should simply acquire the - // lock easily. - - // Once we get the lock, we must have registered. - ACE_ASSERT (td->registered_ != 0); - - td->sync_->release (); - // Release the lock before putting it back to freelist. - } - #if defined (VXWORKS) ACE_thread_t tid = td->self (); #endif /* VXWORKS */ @@ -1296,15 +1301,6 @@ ACE_Thread_Manager::at_exit (void *object, param); } -int -ACE_Thread_Manager::acquire_release (void) -{ - // Just try to acquire the lock then release it. - ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, - this->lock_, -1)); - return 0; -} - // Must be called when thread goes out of scope to clean up its table // slot. @@ -1791,7 +1787,7 @@ ACE_Thread_Control::dump (void) const } int -ACE_Thread_Control::insert (ACE_Thread_Manager *tm) +ACE_Thread_Control::insert (ACE_Thread_Manager *tm, int insert) { ACE_TRACE ("ACE_Thread_Control::insert"); @@ -1799,7 +1795,10 @@ ACE_Thread_Control::insert (ACE_Thread_Manager *tm) ACE_Thread::self (t_id); this->tm_ = tm; - return this->tm_->insert_thr (ACE_Thread::self (), t_id); + if (insert) + return this->tm_->insert_thr (ACE_Thread::self (), t_id); + else + return 0; } // Initialize the thread controller. |