aboutsummaryrefslogtreecommitdiff
path: root/gold/workqueue-threads.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2011-07-28 23:25:06 +0000
committerCary Coutant <ccoutant@google.com>2011-07-28 23:25:06 +0000
commitdcd8d12e1c020d87f7d3920438cf7327eb886008 (patch)
tree07df900db4681ba52b6ce1365e9f9b70e2afe40f /gold/workqueue-threads.cc
parenta27e437177412e5b52999723f3c5d5d0d37b9087 (diff)
downloadgdb-dcd8d12e1c020d87f7d3920438cf7327eb886008.zip
gdb-dcd8d12e1c020d87f7d3920438cf7327eb886008.tar.gz
gdb-dcd8d12e1c020d87f7d3920438cf7327eb886008.tar.bz2
* 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.
Diffstat (limited to 'gold/workqueue-threads.cc')
-rw-r--r--gold/workqueue-threads.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/gold/workqueue-threads.cc b/gold/workqueue-threads.cc
index 60d4adc..de2ce5b 100644
--- a/gold/workqueue-threads.cc
+++ b/gold/workqueue-threads.cc
@@ -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;