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

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

Issue 1275353005: VM thread shutdown. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 5 years, 4 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
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 "platform/globals.h" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "vm/os_thread.h" 8 #include "vm/os_thread.h"
9 9
10 #include <process.h> // NOLINT 10 #include <process.h> // NOLINT
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 // Close the handle, so we don't leak the thread object. 66 // Close the handle, so we don't leak the thread object.
67 CloseHandle(reinterpret_cast<HANDLE>(thread)); 67 CloseHandle(reinterpret_cast<HANDLE>(thread));
68 68
69 return 0; 69 return 0;
70 } 70 }
71 71
72 ThreadLocalKey OSThread::kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES; 72 ThreadLocalKey OSThread::kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES;
73 ThreadId OSThread::kInvalidThreadId = 0; 73 ThreadId OSThread::kInvalidThreadId = 0;
74 ThreadJoinId OSThread::kInvalidThreadJoinId = 0;
74 75
75 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor unused) { 76 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor unused) {
76 ThreadLocalKey key = TlsAlloc(); 77 ThreadLocalKey key = TlsAlloc();
77 if (key == kUnsetThreadLocalKey) { 78 if (key == kUnsetThreadLocalKey) {
78 FATAL1("TlsAlloc failed %d", GetLastError()); 79 FATAL1("TlsAlloc failed %d", GetLastError());
79 } 80 }
80 return key; 81 return key;
81 } 82 }
82 83
83 84
(...skipping 10 matching lines...) Expand all
94 const int kStackSize = (128 * kWordSize * KB); 95 const int kStackSize = (128 * kWordSize * KB);
95 return kStackSize; 96 return kStackSize;
96 } 97 }
97 98
98 99
99 ThreadId OSThread::GetCurrentThreadId() { 100 ThreadId OSThread::GetCurrentThreadId() {
100 return ::GetCurrentThreadId(); 101 return ::GetCurrentThreadId();
101 } 102 }
102 103
103 104
104 bool OSThread::Join(ThreadId id) { 105 ThreadJoinId OSThread::GetCurrentThreadJoinId() {
105 HANDLE handle = OpenThread(SYNCHRONIZE, false, id); 106 return ::GetCurrentThreadId();
106 if (handle == INVALID_HANDLE_VALUE) {
107 return false;
108 }
109 DWORD res = WaitForSingleObject(handle, INFINITE);
110 CloseHandle(handle);
111 return res == WAIT_OBJECT_0;
112 } 107 }
113 108
114 109
110 void OSThread::Join(ThreadJoinId id) {
111 HANDLE handle = OpenThread(SYNCHRONIZE, false, id);
112 ASSERT(handle != INVALID_HANDLE_VALUE);
113 DWORD res = WaitForSingleObject(handle, INFINITE);
114 CloseHandle(handle);
115 ASSERT(res == WAIT_OBJECT_0);
116 }
117
118
115 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { 119 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) {
116 ASSERT(sizeof(id) <= sizeof(intptr_t)); 120 ASSERT(sizeof(id) <= sizeof(intptr_t));
117 return static_cast<intptr_t>(id); 121 return static_cast<intptr_t>(id);
118 } 122 }
119 123
120 124
121 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { 125 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) {
122 return static_cast<ThreadId>(id); 126 return static_cast<ThreadId>(id);
123 } 127 }
124 128
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // timeout before we signal it, that object will get an extra 460 // timeout before we signal it, that object will get an extra
457 // signal. This will be treated as a spurious wake-up and is OK 461 // signal. This will be treated as a spurious wake-up and is OK
458 // since all uses of monitors should recheck the condition after a 462 // since all uses of monitors should recheck the condition after a
459 // Wait. 463 // Wait.
460 data_.SignalAndRemoveAllWaiters(); 464 data_.SignalAndRemoveAllWaiters();
461 } 465 }
462 466
463 } // namespace dart 467 } // namespace dart
464 468
465 #endif // defined(TARGET_OS_WINDOWS) 469 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698