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

Unified Diff: runtime/bin/thread_win.cc

Issue 1410293006: Use ExitProcess on Windows. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add comment Created 5 years, 2 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_win.h ('k') | runtime/platform/globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/thread_win.cc
diff --git a/runtime/bin/thread_win.cc b/runtime/bin/thread_win.cc
index a69f82cb37cdc151906ef3733ee690fbe53720ea..05949a1eab0e0c3859504d12c464005f2909cfff 100644
--- a/runtime/bin/thread_win.cc
+++ b/runtime/bin/thread_win.cc
@@ -104,12 +104,22 @@ ThreadId Thread::GetCurrentThreadId() {
bool Thread::Join(ThreadId id) {
HANDLE handle = OpenThread(SYNCHRONIZE, false, id);
- if (handle == INVALID_HANDLE_VALUE) {
+
+ // TODO(zra): OSThread::Start() closes the handle to the thread. Thus, by the
+ // time we try to join the thread, its resources may have already been
+ // reclaimed, and joining will fail. This can be avoided in a couple of ways.
+ // First, GetCurrentThreadJoinId could call OpenThread and return a handle.
+ // This is bad, because each of those handles would have to be closed.
+ // Second OSThread could be refactored to no longer be AllStatic. Then the
+ // handle could be cached in the object by the Start method.
+ if (handle == NULL) {
return false;
}
+
DWORD res = WaitForSingleObject(handle, INFINITE);
CloseHandle(handle);
- return res == WAIT_OBJECT_0;
+ ASSERT(res == WAIT_OBJECT_0);
+ return true;
}
« no previous file with comments | « runtime/bin/thread_win.h ('k') | runtime/platform/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698