Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: runtime/bin/thread_pool.cc

Issue 9255012: Add MutexLocker and MonitorLocker to platform/bin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « runtime/bin/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698