| 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" // 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 HANDLE handle = OpenThread(SYNCHRONIZE, false, id); | 111 HANDLE handle = OpenThread(SYNCHRONIZE, false, id); |
| 112 | 112 |
| 113 // TODO(zra): OSThread::Start() closes the handle to the thread. Thus, by the | 113 // TODO(zra): OSThread::Start() closes the handle to the thread. Thus, by the |
| 114 // time we try to join the thread, its resources may have already been | 114 // time we try to join the thread, its resources may have already been |
| 115 // reclaimed, and joining will fail. This can be avoided in a couple of ways. | 115 // reclaimed, and joining will fail. This can be avoided in a couple of ways. |
| 116 // First, GetCurrentThreadJoinId could call OpenThread and return a handle. | 116 // First, GetCurrentThreadJoinId could call OpenThread and return a handle. |
| 117 // This is bad, because each of those handles would have to be closed. | 117 // This is bad, because each of those handles would have to be closed. |
| 118 // Second OSThread could be refactored to no longer be AllStatic. Then the | 118 // Second OSThread could be refactored to no longer be AllStatic. Then the |
| 119 // handle could be cached in the object by the Start method. | 119 // handle could be cached in the object by the Start method. |
| 120 if (handle == NULL) { | 120 if (handle == NULL) { |
| 121 ASSERT(GetLastError() == ERROR_INVALID_PARAMETER); | |
| 122 return; | 121 return; |
| 123 } | 122 } |
| 124 | 123 |
| 125 DWORD res = WaitForSingleObject(handle, INFINITE); | 124 DWORD res = WaitForSingleObject(handle, INFINITE); |
| 126 CloseHandle(handle); | 125 CloseHandle(handle); |
| 127 ASSERT(res == WAIT_OBJECT_0); | 126 ASSERT(res == WAIT_OBJECT_0); |
| 128 } | 127 } |
| 129 | 128 |
| 130 | 129 |
| 131 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { | 130 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 // timeout before we signal it, that object will get an extra | 471 // timeout before we signal it, that object will get an extra |
| 473 // signal. This will be treated as a spurious wake-up and is OK | 472 // signal. This will be treated as a spurious wake-up and is OK |
| 474 // since all uses of monitors should recheck the condition after a | 473 // since all uses of monitors should recheck the condition after a |
| 475 // Wait. | 474 // Wait. |
| 476 data_.SignalAndRemoveAllWaiters(); | 475 data_.SignalAndRemoveAllWaiters(); |
| 477 } | 476 } |
| 478 | 477 |
| 479 } // namespace dart | 478 } // namespace dart |
| 480 | 479 |
| 481 #endif // defined(TARGET_OS_WINDOWS) | 480 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |