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

Unified Diff: runtime/vm/thread_pool.cc

Issue 1555643002: Thread fixes for shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years 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
« runtime/vm/os_thread.cc ('K') | « runtime/vm/os_thread.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_pool.cc
diff --git a/runtime/vm/thread_pool.cc b/runtime/vm/thread_pool.cc
index 86d2f609db871a78995d25f75e8118c1e8c53a0b..02f406a0490750fbce0e53c2c10dfe57830dcc64 100644
--- a/runtime/vm/thread_pool.cc
+++ b/runtime/vm/thread_pool.cc
@@ -107,10 +107,16 @@ void ThreadPool::Shutdown() {
while (current != NULL) {
Worker* next = current->all_next_;
ThreadId currentId = current->id();
- if (currentId != id) {
+ ASSERT(id != currentId);
+ if (currentId == OSThread::kInvalidThreadId) {
+ // If the thread id is invalid, it means the thread never started
+ // because OSThread creation was disabled. Destroy the Task and Worker.
+ delete current->task_;
+ delete current;
+ } else {
AddWorkerToShutdownList(current);
+ current->Shutdown();
}
- current->Shutdown();
current = next;
}
saved = NULL;
@@ -258,6 +264,7 @@ bool ThreadPool::ReleaseIdleWorker(Worker* worker) {
// Only call while holding the exit_monitor_
void ThreadPool::AddWorkerToShutdownList(Worker* worker) {
+ ASSERT(exit_monitor_.IsOwnedByCurrentThread());
worker->shutdown_next_ = shutting_down_workers_;
shutting_down_workers_ = worker;
}
@@ -267,6 +274,7 @@ void ThreadPool::AddWorkerToShutdownList(Worker* worker) {
bool ThreadPool::RemoveWorkerFromShutdownList(Worker* worker) {
ASSERT(worker != NULL);
ASSERT(shutting_down_workers_ != NULL);
+ ASSERT(exit_monitor_.IsOwnedByCurrentThread());
// Special case head of list.
if (shutting_down_workers_ == worker) {
« runtime/vm/os_thread.cc ('K') | « runtime/vm/os_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698