@@ -47,7 +47,7 @@ static void BackgroundRunner(void* data) {
4747class BackgroundTaskRunner ::DelayedTaskScheduler {
4848 public:
4949 explicit DelayedTaskScheduler (TaskQueue<Task>* tasks)
50- : pending_worker_tasks_ (tasks) {}
50+ : background_tasks_ (tasks) {}
5151
5252 std::unique_ptr<uv_thread_t > Start () {
5353 auto start_thread = [](void * data) {
@@ -139,7 +139,7 @@ class BackgroundTaskRunner::DelayedTaskScheduler {
139139 static void RunTask (uv_timer_t * timer) {
140140 DelayedTaskScheduler* scheduler =
141141 ContainerOf (&DelayedTaskScheduler::loop_, timer->loop );
142- scheduler->pending_worker_tasks_ ->Push (scheduler->TakeTimerTask (timer));
142+ scheduler->background_tasks_ ->Push (scheduler->TakeTimerTask (timer));
143143 }
144144
145145 std::unique_ptr<Task> TakeTimerTask (uv_timer_t * timer) {
@@ -153,7 +153,7 @@ class BackgroundTaskRunner::DelayedTaskScheduler {
153153 }
154154
155155 uv_sem_t ready_;
156- TaskQueue<v8::Task>* pending_worker_tasks_ ;
156+ TaskQueue<v8::Task>* background_tasks_ ;
157157
158158 TaskQueue<v8::Task> tasks_;
159159 uv_loop_t loop_;
@@ -162,17 +162,20 @@ class BackgroundTaskRunner::DelayedTaskScheduler {
162162};
163163
164164BackgroundTaskRunner::BackgroundTaskRunner (int thread_pool_size) {
165- Mutex::ScopedLock lock (platform_workers_mutex_);
166- pending_platform_workers_ = thread_pool_size;
165+ Mutex platform_workers_mutex;
166+ ConditionVariable platform_workers_ready;
167+
168+ Mutex::ScopedLock lock (platform_workers_mutex);
169+ int pending_platform_workers = thread_pool_size;
167170
168171 delayed_task_scheduler_.reset (
169172 new DelayedTaskScheduler (&background_tasks_));
170173 threads_.push_back (delayed_task_scheduler_->Start ());
171174
172175 for (int i = 0 ; i < thread_pool_size; i++) {
173176 PlatformWorkerData* worker_data = new PlatformWorkerData{
174- &background_tasks_, &platform_workers_mutex_ ,
175- &platform_workers_ready_ , &pending_platform_workers_ , i
177+ &background_tasks_, &platform_workers_mutex ,
178+ &platform_workers_ready , &pending_platform_workers , i
176179 };
177180 std::unique_ptr<uv_thread_t > t { new uv_thread_t () };
178181 if (uv_thread_create (t.get (), BackgroundRunner, worker_data) != 0 )
@@ -182,8 +185,8 @@ BackgroundTaskRunner::BackgroundTaskRunner(int thread_pool_size) {
182185
183186 // Wait for platform workers to initialize before continuing with the
184187 // bootstrap.
185- while (pending_platform_workers_ > 0 ) {
186- platform_workers_ready_ .Wait (lock);
188+ while (pending_platform_workers > 0 ) {
189+ platform_workers_ready .Wait (lock);
187190 }
188191}
189192
0 commit comments