summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-11 05:29:33 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-11 05:29:33 +0000
commit48adf6bc4d2cb81c5bd542890ebe8a281510f3ac (patch)
treeba85bb509e6450faa09da37506a023e6fb2a93fc
parent431388bf5c64d9d796d126ca81981fe363aeb393 (diff)
downloadATCD-48adf6bc4d2cb81c5bd542890ebe8a281510f3ac.tar.gz
More Thread_Manager optimization.
-rw-r--r--ace/Log_Msg.cpp15
-rw-r--r--ace/Log_Msg.h7
-rw-r--r--ace/OS.cpp6
-rw-r--r--ace/Thread_Manager.cpp51
-rw-r--r--ace/Thread_Manager.h17
5 files changed, 48 insertions, 48 deletions
diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp
index 7e37ad8d651..b7bf71b23ca 100644
--- a/ace/Log_Msg.cpp
+++ b/ace/Log_Msg.cpp
@@ -737,7 +737,7 @@ ACE_Log_Msg::log (const ASYS_TCHAR *format_str,
type = SKIP_NUL_LOCATE;
(void) this->inc ();
break;
-
+
case '}': // indent, then decrement trace_depth
type = SKIP_NUL_LOCATE;
(void) this->dec ();
@@ -747,7 +747,7 @@ ACE_Log_Msg::log (const ASYS_TCHAR *format_str,
// according to %I
*bp++ = '\n';
/* fallthrough */
-
+
case 'I': // Indent with nesting_depth*width spaces
type = SKIP_SPRINTF;
if (!wpc) w[wpc++] = 1;
@@ -914,7 +914,7 @@ ACE_Log_Msg::log (const ASYS_TCHAR *format_str,
// Write the <log_record> to the appropriate location.
ssize_t result = this->log (log_record, abort_prog);
-
+
if (abort_prog)
{
// *Always* print a message to stderr if we're aborting. We
@@ -923,7 +923,7 @@ ACE_Log_Msg::log (const ASYS_TCHAR *format_str,
log_record.print (ACE_Log_Msg::local_host_, 0);
ACE_OS::exit (exit_value);
}
-
+
return result;
}
@@ -1173,13 +1173,12 @@ ACE_Log_Msg::thr_desc (void) const
}
void
-ACE_Log_Msg::thr_desc (ACE_Thread_Descriptor *td,
- ACE_Thread_Manager *thr_mgr)
+ACE_Log_Msg::thr_desc (ACE_Thread_Descriptor *td)
{
this->thr_desc_ = td;
- if (thr_mgr != 0)
- thr_mgr->acquire_release ();
+ if (td != 0)
+ td->acquire_release ();
}
// Enable the tracing facility on a per-thread basis.
diff --git a/ace/Log_Msg.h b/ace/Log_Msg.h
index 2b5fb1f56c4..4889ca8f8b9 100644
--- a/ace/Log_Msg.h
+++ b/ace/Log_Msg.h
@@ -178,7 +178,7 @@ public:
void sync (const ASYS_TCHAR *program_name);
// Call after doing a <fork> to resynchronize the process id and
// <program_name> variables.
- // @@ Does this function mean anything on Windows?
+ // @@ Does this function mean anything on Windows?
// = Set/get methods. Note that these are non-static and thus will
// be thread-specific.
@@ -250,10 +250,9 @@ public:
ACE_Thread_Descriptor *thr_desc (void) const;
// Get the TSS thread descriptor.
- void thr_desc (ACE_Thread_Descriptor *td,
- ACE_Thread_Manager *thr_mgr = 0);
+ void thr_desc (ACE_Thread_Descriptor *td);
// Set the TSS thread descriptor. This method will call
- // thr_mgr->acquire_release to block execution until this call
+ // td->acquire_release to block execution until this call
// return.
// = Stop/start/query tracing status on a per-thread basis...
diff --git a/ace/OS.cpp b/ace/OS.cpp
index f8d7ae5c200..f696893f7a4 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -72,7 +72,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Time_Value)
// Static constant to remove time skew between FILETIME and POSIX
// time.
-//
+//
// In the beginning (Jan. 1, 1601), there was no time and no computer.
// And Bill said: "Let there be time," and there was time....
const DWORDLONG ACE_Time_Value::FILETIME_to_timval_skew = 0x19db1ded53e8000i64;
@@ -107,7 +107,7 @@ ACE_Time_Value::operator FILETIME () const
FILETIME file_time;
file_time.dwLowDateTime = _100ns.LowPart;
file_time.dwHighDateTime = _100ns.HighPart;
-
+
return file_time;
}
@@ -1800,7 +1800,7 @@ ACE_Thread_Adapter::inherit_log_msg (void)
// descriptor in.
if (this->thr_desc_ != 0)
- ACE_LOG_MSG->thr_desc (this->thr_desc_, this->thr_mgr_);
+ ACE_LOG_MSG->thr_desc (this->thr_desc_);
// Block the thread from proceeding until
// thread manager has thread descriptor ready.
#endif /* ACE_THREADS_DONT_INHERIT_LOG_MSG */
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.
diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h
index ee9e2844ca9..ed438682806 100644
--- a/ace/Thread_Manager.h
+++ b/ace/Thread_Manager.h
@@ -127,6 +127,15 @@ public:
long flags (void) const;
// Get the thread creation flags.
+ void acquire_release (void);
+ // Do nothing but to acquire the thread descriptor's lock and
+ // release. This will first check if the thread is registered or
+ // not. If it is already registered, there's no need to reacquire
+ // the lock again. This is used mainly to get newly spawned thread
+ // in synch with thread manager and prevent it from accessing its
+ // thread descriptor before it gets fully built. This function is
+ // only called from ACE_Log_Msg::thr_desc.
+
ACE_INLINE void set_next (ACE_Thread_Descriptor *td);
ACE_INLINE ACE_Thread_Descriptor *get_next (void);
// Set/get the <next_> pointer. These are required by the
@@ -456,12 +465,6 @@ public:
// array) to be destroyed. "cleanup_hook", for example, may delete
// the object (or array).
- int acquire_release (void);
- // Do nothing but to acquire the thread manager's lock and release.
- // This is used mainly to get newly spawned thread in synch with
- // thread manager and prevent it from accessing its thread
- // descriptor before it gets fully built.
-
void wait_on_exit (int dowait);
int wait_on_exit (void);
// Access function to determine whether the Thread_Manager will
@@ -639,7 +642,7 @@ public:
// Remove this thread from its associated <Thread_Manager> and exit
// the thread if <do_thr_exit> is enabled.
- int insert (ACE_Thread_Manager *tm);
+ int insert (ACE_Thread_Manager *tm, int insert = 0);
// Store the <Thread_Manager> and use it to register ourselves for
// correct shutdown.