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

Unified Diff: runtime/bin/thread_pool_linux.cc

Issue 9231020: Use platform implementation of Monitor in thread pool (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_pool_linux.h ('k') | runtime/bin/thread_pool_macos.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/thread_pool_linux.cc
diff --git a/runtime/bin/thread_pool_linux.cc b/runtime/bin/thread_pool_linux.cc
index f0e37342d5c2d0d4c1adac680efdb9e121453fae..ce6c10f2de93a22f5b7fa324383a7e47612b6266 100644
--- a/runtime/bin/thread_pool_linux.cc
+++ b/runtime/bin/thread_pool_linux.cc
@@ -6,65 +6,6 @@
#include "bin/thread_pool.h"
-TaskQueue::TaskQueue() : terminate_(false), head_(NULL), tail_(NULL) {
- int result;
-
- result = pthread_mutex_init(data_.mutex(), NULL);
- if (result != 0) {
- FATAL("pthread_mutex_init failed");
- }
-
- result = pthread_cond_init(data_.cond(), NULL);
- if (result != 0) {
- FATAL("pthread_cond_init failed");
- }
-}
-
-
-void TaskQueue::Insert(TaskQueueEntry* entry) {
- pthread_mutex_lock(data_.mutex());
- if (head_ == NULL) {
- head_ = entry;
- tail_ = entry;
- pthread_cond_signal(data_.cond());
- } else {
- tail_->set_next(entry);
- tail_ = entry;
- }
- pthread_mutex_unlock(data_.mutex());
-}
-
-
-TaskQueueEntry* TaskQueue::Remove() {
- pthread_mutex_lock(data_.mutex());
- TaskQueueEntry* result = head_;
- while (result == NULL) {
- if (terminate_) {
- pthread_mutex_unlock(data_.mutex());
- return NULL;
- }
- pthread_cond_wait(data_.cond(), data_.mutex());
- if (terminate_) {
- pthread_mutex_unlock(data_.mutex());
- return NULL;
- }
- result = head_;
- }
- head_ = result->next();
- ASSERT(head_ != NULL || tail_ == result);
- pthread_mutex_unlock(data_.mutex());
- return result;
-}
-
-
-void TaskQueue::Shutdown() {
- pthread_mutex_lock(data_.mutex());
- terminate_ = true;
- pthread_cond_broadcast(data_.cond());
- pthread_mutex_unlock(data_.mutex());
-}
-
-
void ThreadPool::Start() {
pthread_t* threads
= reinterpret_cast<pthread_t*>(calloc(size_, sizeof(pthread_t*))); // NOLINT
« no previous file with comments | « runtime/bin/thread_pool_linux.h ('k') | runtime/bin/thread_pool_macos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698