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

Unified Diff: runtime/vm/thread_pool.cc

Issue 1978153002: Uses an open thread handle as the ThreadJoinId on Windows. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
Index: runtime/vm/thread_pool.cc
diff --git a/runtime/vm/thread_pool.cc b/runtime/vm/thread_pool.cc
index fb0f7d7c69b2fac5d7d1af0843eaa2e08c87500f..cd39a59afe26177f14dedc7f923d1b49bc434ef0 100644
--- a/runtime/vm/thread_pool.cc
+++ b/runtime/vm/thread_pool.cc
@@ -212,6 +212,15 @@ bool ThreadPool::RemoveWorkerFromAllList(Worker* worker) {
}
+void ThreadPool::SetIdleLocked(Worker* worker) {
siva 2016/05/16 17:59:27 ASSERT(mutex_.IsOwnedByCurrentThread());
zra 2016/05/16 20:32:55 Done.
+ ASSERT(worker->owned_ && !IsIdle(worker));
+ worker->idle_next_ = idle_workers_;
+ idle_workers_ = worker;
+ count_idle_++;
+ count_running_--;
+}
+
+
void ThreadPool::SetIdleAndReapExited(Worker* worker) {
JoinList* list = NULL;
{
@@ -219,17 +228,25 @@ void ThreadPool::SetIdleAndReapExited(Worker* worker) {
if (shutting_down_) {
return;
}
- ASSERT(worker->owned_ && !IsIdle(worker));
- worker->idle_next_ = idle_workers_;
- idle_workers_ = worker;
- count_idle_++;
- count_running_--;
-
- // While we have the lock, opportunistically grab and clear the join_list_.
+ if (join_list_ == NULL) {
+ // Nothing to join, add to the idle list and return.
+ SetIdleLocked(worker);
+ return;
+ }
+ // There is something to join. Grab the join list, drop the lock, do the
+ // join, then grab the lock again and add to the idle list.
list = join_list_;
join_list_ = NULL;
}
JoinList::Join(&list);
+
+ {
+ MutexLocker ml(&mutex_);
+ if (shutting_down_) {
+ return;
+ }
+ SetIdleLocked(worker);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698