OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/thread_pool.h" | 5 #include "vm/thread_pool.h" |
6 | 6 |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
9 | 9 |
10 namespace dart { | 10 namespace dart { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 void ThreadPool::Worker::Loop() { | 267 void ThreadPool::Worker::Loop() { |
268 MonitorLocker ml(&monitor_); | 268 MonitorLocker ml(&monitor_); |
269 int64_t idle_start; | 269 int64_t idle_start; |
270 while (true) { | 270 while (true) { |
271 ASSERT(task_ != NULL); | 271 ASSERT(task_ != NULL); |
272 Task* task = task_; | 272 Task* task = task_; |
273 task_ = NULL; | 273 task_ = NULL; |
274 | 274 |
275 // Release monitor while handling the task. | 275 // Release monitor while handling the task. |
276 monitor_.Exit(); | 276 monitor_.Exit(); |
277 Thread::EnsureInit(); | |
278 task->Run(); | 277 task->Run(); |
279 ASSERT(Isolate::Current() == NULL); | 278 ASSERT(Isolate::Current() == NULL); |
280 // Prevent unintended sharing of state between tasks. | |
281 Thread::CleanUp(); | |
282 delete task; | 279 delete task; |
283 monitor_.Enter(); | 280 monitor_.Enter(); |
284 | 281 |
285 ASSERT(task_ == NULL); | 282 ASSERT(task_ == NULL); |
286 if (IsDone()) { | 283 if (IsDone()) { |
287 return; | 284 return; |
288 } | 285 } |
289 ASSERT(pool_ != NULL); | 286 ASSERT(pool_ != NULL); |
290 pool_->SetIdle(this); | 287 pool_->SetIdle(this); |
291 idle_start = OS::GetCurrentTimeMillis(); | 288 idle_start = OS::GetCurrentTimeMillis(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 worker->all_next_ == NULL && | 323 worker->all_next_ == NULL && |
327 worker->idle_next_ == NULL); | 324 worker->idle_next_ == NULL); |
328 | 325 |
329 // The exit monitor is only used during testing. | 326 // The exit monitor is only used during testing. |
330 if (ThreadPool::exit_monitor_) { | 327 if (ThreadPool::exit_monitor_) { |
331 MonitorLocker ml(ThreadPool::exit_monitor_); | 328 MonitorLocker ml(ThreadPool::exit_monitor_); |
332 (*ThreadPool::exit_count_)++; | 329 (*ThreadPool::exit_count_)++; |
333 ml.Notify(); | 330 ml.Notify(); |
334 } | 331 } |
335 delete worker; | 332 delete worker; |
| 333 #if defined(TARGET_OS_WINDOWS) |
| 334 Thread::CleanUp(); |
| 335 #endif |
336 } | 336 } |
337 | 337 |
338 } // namespace dart | 338 } // namespace dart |
OLD | NEW |