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

Unified Diff: dart/runtime/vm/thread_interrupter.cc

Issue 298153002: Version 1.4.1 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.4/
Patch Set: Created 6 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
« no previous file with comments | « dart/runtime/vm/profiler.cc ('k') | dart/runtime/vm/thread_interrupter_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/vm/thread_interrupter.cc
===================================================================
--- dart/runtime/vm/thread_interrupter.cc (revision 36615)
+++ dart/runtime/vm/thread_interrupter.cc (working copy)
@@ -86,25 +86,28 @@
void ThreadInterrupter::Shutdown() {
- if (shutdown_) {
- // Already shutdown.
- return;
- }
- ASSERT(initialized_);
- if (FLAG_trace_thread_interrupter) {
- OS::Print("ThreadInterrupter shutting down.\n");
- }
{
- MonitorLocker ml(monitor_);
+ MonitorLocker shutdown_ml(monitor_);
+ if (shutdown_) {
+ // Already shutdown.
+ return;
+ }
shutdown_ = true;
- }
- {
- MonitorLocker shutdown_ml(monitor_);
+ ASSERT(initialized_);
+ if (FLAG_trace_thread_interrupter) {
+ OS::Print("ThreadInterrupter shutting down.\n");
+ }
while (thread_running_) {
shutdown_ml.Wait();
}
+ // Join in the interrupter thread. On Windows, a thread's exit-code can
+ // leak into the process's exit-code, if exiting 'at same time' as the
+ // process ends.
+ if (interrupter_thread_id_ != Thread::kInvalidThreadId) {
+ Thread::Join(interrupter_thread_id_);
+ interrupter_thread_id_ = Thread::kInvalidThreadId;
+ }
}
- interrupter_thread_id_ = Thread::kInvalidThreadId;
if (FLAG_trace_thread_interrupter) {
OS::Print("ThreadInterrupter shut down.\n");
}
@@ -234,8 +237,8 @@
{
// Signal to main thread we are ready.
MonitorLocker startup_ml(monitor_);
+ interrupter_thread_id_ = Thread::GetCurrentThreadId();
thread_running_ = true;
- interrupter_thread_id_ = Thread::GetCurrentThreadId();
startup_ml.Notify();
}
{
« no previous file with comments | « dart/runtime/vm/profiler.cc ('k') | dart/runtime/vm/thread_interrupter_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698