OLD | NEW |
---|---|
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" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 #include "bin/thread_win.h" | 9 #include "bin/thread_win.h" |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 return kStackSize; | 97 return kStackSize; |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 ThreadId Thread::GetCurrentThreadId() { | 101 ThreadId Thread::GetCurrentThreadId() { |
102 return ::GetCurrentThreadId(); | 102 return ::GetCurrentThreadId(); |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 bool Thread::Join(ThreadId id) { | 106 bool Thread::Join(ThreadId id) { |
107 HANDLE handle = OpenThread(SYNCHRONIZE, false, id); | 107 return false; |
108 | |
109 // TODO(zra): OSThread::Start() closes the handle to the thread. Thus, by the | |
110 // time we try to join the thread, its resources may have already been | |
111 // reclaimed, and joining will fail. This can be avoided in a couple of ways. | |
112 // First, GetCurrentThreadJoinId could call OpenThread and return a handle. | |
113 // This is bad, because each of those handles would have to be closed. | |
114 // Second OSThread could be refactored to no longer be AllStatic. Then the | |
115 // handle could be cached in the object by the Start method. | |
116 if (handle == NULL) { | |
117 return false; | |
118 } | |
119 | |
120 DWORD res = WaitForSingleObject(handle, INFINITE); | |
121 CloseHandle(handle); | |
122 ASSERT(res == WAIT_OBJECT_0); | |
123 return true; | |
124 } | 108 } |
siva
2016/05/16 17:59:27
The Thread::Join function doesn't seem to be used
zra
2016/05/16 20:32:54
Done.
| |
125 | 109 |
126 | 110 |
127 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) { | 111 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) { |
128 ASSERT(sizeof(id) <= sizeof(intptr_t)); | 112 ASSERT(sizeof(id) <= sizeof(intptr_t)); |
129 return static_cast<intptr_t>(id); | 113 return static_cast<intptr_t>(id); |
130 } | 114 } |
131 | 115 |
132 | 116 |
133 bool Thread::Compare(ThreadId a, ThreadId b) { | 117 bool Thread::Compare(ThreadId a, ThreadId b) { |
134 return (a == b); | 118 return (a == b); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 // signal. This will be treated as a spurious wake-up and is OK | 437 // signal. This will be treated as a spurious wake-up and is OK |
454 // since all uses of monitors should recheck the condition after a | 438 // since all uses of monitors should recheck the condition after a |
455 // Wait. | 439 // Wait. |
456 data_.SignalAndRemoveAllWaiters(); | 440 data_.SignalAndRemoveAllWaiters(); |
457 } | 441 } |
458 | 442 |
459 } // namespace bin | 443 } // namespace bin |
460 } // namespace dart | 444 } // namespace dart |
461 | 445 |
462 #endif // defined(TARGET_OS_WINDOWS) | 446 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |