* workqueue-internal.h (Workqueue_threader::should_cancel_thread):
authorCary Coutant <ccoutant@google.com>
Thu, 28 Jul 2011 23:25:06 +0000 (23:25 +0000)
committerCary Coutant <ccoutant@google.com>
Thu, 28 Jul 2011 23:25:06 +0000 (23:25 +0000)
Add thread_number parameter.
(Workqueue_threader_threadpool::should_cancel_thread): Likewise.
* workqueue-threads.cc
(Workqueue_threader_threadpool::should_cancel_thread): Cancel
current thread if its thread number is greater than desired thread
count.
* workqueue.cc (Workqueue_threader_single::should_cancel_thread):
Add thread_number parameter.
(Workqueue::should_cancel_thread): Likewise.
(Workqueue::find_runnable_or_wait): Pass thread_number to
should_cancel_thread.
* workqueue.h (Workqueue::should_cancel_thread): Add thread_number
parameter.

gold/ChangeLog
gold/workqueue-internal.h
gold/workqueue-threads.cc
gold/workqueue.cc
gold/workqueue.h

index c894c710b7bcdfc3bfdd624410206aa2e1a074ed..08fd41f93e863759ee313151def8fd9562fb76c1 100644 (file)
@@ -1,3 +1,20 @@
+2011-07-28  Cary Coutant  <ccoutant@google.com>
+
+       * workqueue-internal.h (Workqueue_threader::should_cancel_thread):
+       Add thread_number parameter.
+       (Workqueue_threader_threadpool::should_cancel_thread): Likewise.
+       * workqueue-threads.cc
+       (Workqueue_threader_threadpool::should_cancel_thread): Cancel
+       current thread if its thread number is greater than desired thread
+       count.
+       * workqueue.cc (Workqueue_threader_single::should_cancel_thread):
+       Add thread_number parameter.
+       (Workqueue::should_cancel_thread): Likewise.
+       (Workqueue::find_runnable_or_wait): Pass thread_number to
+       should_cancel_thread.
+       * workqueue.h (Workqueue::should_cancel_thread): Add thread_number
+       parameter.
+
 2011-07-22  Sriraman Tallam  <tmsriram@google.com>
 
        * symtab.cc (Symbol_table::add_from_relobj): Mark symbol as referenced
index 684c65ba071c2866bb69c9cf213b550aaf8bc0d1..764dc91b3d363f4c1cfc7af98700ef8ca2975bda 100644 (file)
@@ -56,7 +56,7 @@ class Workqueue_threader
 
   // Return whether to cancel the current thread.
   virtual bool
-  should_cancel_thread() = 0;
+  should_cancel_thread(int thread_number) = 0;
 
  protected:
   // Get the Workqueue.
@@ -84,7 +84,7 @@ class Workqueue_threader_threadpool : public Workqueue_threader
 
   // Return whether to cancel a thread.
   bool
-  should_cancel_thread();
+  should_cancel_thread(int thread_number);
 
   // Process all tasks.  This keeps running until told to cancel.
   void
index 60d4adcbb3a579b4d74628686d6b63cd42c7b5d1..de2ce5bef5022136328a5320ba3238f42a656f8d 100644 (file)
@@ -174,7 +174,7 @@ Workqueue_threader_threadpool::set_thread_count(int thread_count)
 // Return whether the current thread should be cancelled.
 
 bool
-Workqueue_threader_threadpool::should_cancel_thread()
+Workqueue_threader_threadpool::should_cancel_thread(int thread_number)
 {
   // Fast exit without taking a lock.
   if (!this->check_thread_count_)
@@ -182,12 +182,13 @@ Workqueue_threader_threadpool::should_cancel_thread()
 
   {
     Hold_lock hl(this->lock_);
-    if (this->threads_ > this->desired_thread_count_)
+    if (thread_number > this->desired_thread_count_)
       {
        --this->threads_;
+       if (this->threads_ <= this->desired_thread_count_)
+         this->check_thread_count_ = 0;
        return true;
       }
-    this->check_thread_count_ = 0;
   }
 
   return false;
index 6449bbad8462489d18f0ee63db4a4e1aeb97482d..e78e86b9ecc9cab29cbb9f4ae917135268d66751 100644 (file)
@@ -110,7 +110,7 @@ class Workqueue_threader_single : public Workqueue_threader
   { gold_assert(thread_count > 0); }
 
   bool
-  should_cancel_thread()
+  should_cancel_thread(int)
   { return false; }
 };
 
@@ -202,9 +202,9 @@ Workqueue::queue_next(Task* t)
 // Return whether to cancel the current thread.
 
 inline bool
-Workqueue::should_cancel_thread()
+Workqueue::should_cancel_thread(int thread_number)
 {
-  return this->threader_->should_cancel_thread();
+  return this->threader_->should_cancel_thread(thread_number);
 }
 
 // Find a runnable task in TASKS.  Return NULL if none could be found.
@@ -264,7 +264,7 @@ Workqueue::find_runnable_or_wait(int thread_number)
          return NULL;
        }
 
-      if (this->should_cancel_thread())
+      if (this->should_cancel_thread(thread_number))
        return NULL;
 
       gold_debug(DEBUG_TASK, "%3d sleeping", thread_number);
index 9121e10e14f0a210a51bf04326cb5e7bf2a6c9b6..424b5e78ca7a164d11d4152f7be7ffe66337c7ad 100644 (file)
@@ -268,7 +268,7 @@ class Workqueue
 
   // Return whether to cancel this thread.
   bool
-  should_cancel_thread();
+  should_cancel_thread(int thread_number);
 
   // Master Workqueue lock.  This controls access to the following
   // member variables.
This page took 0.033815 seconds and 4 git commands to generate.