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(); |
277 task->Run(); | 278 task->Run(); |
| 279 ASSERT(Isolate::Current() == NULL); |
| 280 // Prevent unintended sharing of state between tasks. |
| 281 Thread::CleanUp(); |
278 delete task; | 282 delete task; |
279 monitor_.Enter(); | 283 monitor_.Enter(); |
280 | 284 |
281 ASSERT(task_ == NULL); | 285 ASSERT(task_ == NULL); |
282 if (IsDone()) { | 286 if (IsDone()) { |
283 return; | 287 return; |
284 } | 288 } |
285 ASSERT(pool_ != NULL); | 289 ASSERT(pool_ != NULL); |
286 pool_->SetIdle(this); | 290 pool_->SetIdle(this); |
287 idle_start = OS::GetCurrentTimeMillis(); | 291 idle_start = OS::GetCurrentTimeMillis(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // The exit monitor is only used during testing. | 329 // The exit monitor is only used during testing. |
326 if (ThreadPool::exit_monitor_) { | 330 if (ThreadPool::exit_monitor_) { |
327 MonitorLocker ml(ThreadPool::exit_monitor_); | 331 MonitorLocker ml(ThreadPool::exit_monitor_); |
328 (*ThreadPool::exit_count_)++; | 332 (*ThreadPool::exit_count_)++; |
329 ml.Notify(); | 333 ml.Notify(); |
330 } | 334 } |
331 delete worker; | 335 delete worker; |
332 } | 336 } |
333 | 337 |
334 } // namespace dart | 338 } // namespace dart |
OLD | NEW |