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

Side by Side Diff: runtime/vm/thread_pool.cc

Issue 1557033002: Fixes for OSThread creation shutdown race. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/os_thread.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/thread_pool.h" 5 #include "vm/thread_pool.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/lockers.h" 8 #include "vm/lockers.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 MonitorLocker eml(&exit_monitor_); 100 MonitorLocker eml(&exit_monitor_);
101 101
102 // First tell all the workers to shut down. 102 // First tell all the workers to shut down.
103 Worker* current = saved; 103 Worker* current = saved;
104 OSThread* os_thread = OSThread::Current(); 104 OSThread* os_thread = OSThread::Current();
105 ASSERT(os_thread != NULL); 105 ASSERT(os_thread != NULL);
106 ThreadId id = os_thread->id(); 106 ThreadId id = os_thread->id();
107 while (current != NULL) { 107 while (current != NULL) {
108 Worker* next = current->all_next_; 108 Worker* next = current->all_next_;
109 ThreadId currentId = current->id(); 109 ThreadId currentId = current->id();
110 ASSERT(id != currentId); 110 if (currentId != id) {
111 if (currentId == OSThread::kInvalidThreadId) {
112 // If the thread id is invalid, it means the thread never started
113 // because OSThread creation was disabled. Destroy the Task and Worker.
114 delete current->task_;
115 delete current;
116 } else {
117 AddWorkerToShutdownList(current); 111 AddWorkerToShutdownList(current);
118 current->Shutdown();
119 } 112 }
113 current->Shutdown();
120 current = next; 114 current = next;
121 } 115 }
122 saved = NULL; 116 saved = NULL;
123 117
124 // Wait until all workers will exit. 118 // Wait until all workers will exit.
125 while (shutting_down_workers_ != NULL) { 119 while (shutting_down_workers_ != NULL) {
126 // Here, we are waiting for workers to exit. When a worker exits we will 120 // Here, we are waiting for workers to exit. When a worker exits we will
127 // be notified. 121 // be notified.
128 eml.Wait(); 122 eml.Wait();
129 } 123 }
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // is not due to a ThreadPool Shutdown. Thus, we simply delete the worker. 476 // is not due to a ThreadPool Shutdown. Thus, we simply delete the worker.
483 // The worker's id is added to the thread pool's join list by 477 // The worker's id is added to the thread pool's join list by
484 // ReleaseIdleWorker, so in the case that the thread pool begins shutting 478 // ReleaseIdleWorker, so in the case that the thread pool begins shutting
485 // down immediately after returning from worker->Loop() above, we still 479 // down immediately after returning from worker->Loop() above, we still
486 // wait for the thread to exit by joining on it in Shutdown(). 480 // wait for the thread to exit by joining on it in Shutdown().
487 delete worker; 481 delete worker;
488 } 482 }
489 } 483 }
490 484
491 } // namespace dart 485 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/os_thread.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698