| Index: runtime/bin/thread_pool.cc
|
| diff --git a/runtime/bin/thread_pool.cc b/runtime/bin/thread_pool.cc
|
| index d93b8f844aa24e5423a2d55032ac1216e9354925..36960a72303b798454eb01b72b3cfa802a1044ce 100644
|
| --- a/runtime/bin/thread_pool.cc
|
| +++ b/runtime/bin/thread_pool.cc
|
| @@ -4,47 +4,45 @@
|
|
|
| #include "bin/thread_pool.h"
|
|
|
| +#include "bin/thread.h"
|
| +
|
| void TaskQueue::Insert(TaskQueueEntry* entry) {
|
| + MonitorLocker monitor(&monitor_);
|
| monitor_.Enter();
|
| if (head_ == NULL) {
|
| head_ = entry;
|
| tail_ = entry;
|
| - monitor_.Notify();
|
| + monitor.Notify();
|
| } else {
|
| tail_->set_next(entry);
|
| tail_ = entry;
|
| }
|
| - monitor_.Exit();
|
| }
|
|
|
|
|
| TaskQueueEntry* TaskQueue::Remove() {
|
| - monitor_.Enter();
|
| + MonitorLocker monitor(&monitor_);
|
| TaskQueueEntry* result = head_;
|
| while (result == NULL) {
|
| if (terminate_) {
|
| - monitor_.Exit();
|
| return NULL;
|
| }
|
| - monitor_.Wait(dart::Monitor::kNoTimeout);
|
| + monitor.Wait();
|
| if (terminate_) {
|
| - monitor_.Exit();
|
| return NULL;
|
| }
|
| result = head_;
|
| }
|
| head_ = result->next();
|
| ASSERT(head_ != NULL || tail_ == result);
|
| - monitor_.Exit();
|
| return result;
|
| }
|
|
|
|
|
| void TaskQueue::Shutdown() {
|
| - monitor_.Enter();
|
| + MonitorLocker monitor(&monitor_);
|
| terminate_ = true;
|
| - monitor_.NotifyAll();
|
| - monitor_.Exit();
|
| + monitor.NotifyAll();
|
| }
|
|
|
|
|
|
|