- Hold_lock hl(this->lock_);
- this->desired_thread_count_ = 0;
- this->task_queue_condvar_.broadcast();
-}
-
-// Run a task. This doesn't actually run the task: it pushes on the
-// queue of tasks to run. This is always called in the main thread.
-
-void
-Workqueue_runner_threadpool::run(Task* t, Task_locker* tl)
-{
- Hold_lock hl(this->lock_);
-
- // This is where we create threads as needed, subject to the limit
- // of the desired thread count.
- gold_assert(this->desired_thread_count_ > 0);
- gold_assert(this->actual_thread_count_ >= this->running_thread_count_);
- if (this->actual_thread_count_ == this->running_thread_count_
- && this->actual_thread_count_ < this->desired_thread_count_)
- {
- // Note that threads delete themselves when they exit, so we
- // don't keep pointers to them.
- new Workqueue_thread(this);
- ++this->actual_thread_count_;
- }
-
- this->task_queue_.push(std::make_pair(t, tl));
- this->task_queue_condvar_.signal();