| 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/thread.h" | 5 #include "platform/thread.h" |
| 6 | 6 |
| 7 #include <process.h> | 7 #include <process.h> |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // When the function returns here close the handle. | 42 // When the function returns here close the handle. |
| 43 CloseHandle(GetCurrentThread()); | 43 CloseHandle(GetCurrentThread()); |
| 44 | 44 |
| 45 return 0; | 45 return 0; |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 int Thread::Start(ThreadStartFunction function, uword parameter) { | 49 int Thread::Start(ThreadStartFunction function, uword parameter) { |
| 50 ThreadStartData* start_data = new ThreadStartData(function, parameter); | 50 ThreadStartData* start_data = new ThreadStartData(function, parameter); |
| 51 uint32_t tid; | 51 uint32_t tid; |
| 52 uintptr_t thread = | 52 uintptr_t thread = _beginthreadex(NULL, Thread::GetMaxStackSize(), |
| 53 _beginthreadex(NULL, 64 * KB, ThreadEntry, start_data, 0, &tid); | 53 ThreadEntry, start_data, 0, &tid); |
| 54 if (thread == -1L || thread == 0) { | 54 if (thread == -1L || thread == 0) { |
| 55 #ifdef DEBUG | 55 #ifdef DEBUG |
| 56 fprintf(stderr, "_beginthreadex error: %d (%s)\n", errno, strerror(errno)); | 56 fprintf(stderr, "_beginthreadex error: %d (%s)\n", errno, strerror(errno)); |
| 57 #endif | 57 #endif |
| 58 return errno; | 58 return errno; |
| 59 } | 59 } |
| 60 | 60 |
| 61 return 0; | 61 return 0; |
| 62 } | 62 } |
| 63 | 63 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 76 | 76 |
| 77 void Thread::DeleteThreadLocal(ThreadLocalKey key) { | 77 void Thread::DeleteThreadLocal(ThreadLocalKey key) { |
| 78 ASSERT(key != kUnsetThreadLocalKey); | 78 ASSERT(key != kUnsetThreadLocalKey); |
| 79 BOOL result = TlsFree(key); | 79 BOOL result = TlsFree(key); |
| 80 if (!result) { | 80 if (!result) { |
| 81 FATAL("TlsFree failed"); | 81 FATAL("TlsFree failed"); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 | 85 |
| 86 intptr_t Thread::GetMaxStackSize() { |
| 87 const int kStackSize = (256 * KB); |
| 88 return kStackSize; |
| 89 } |
| 90 |
| 91 |
| 86 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { | 92 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
| 87 ASSERT(key != kUnsetThreadLocalKey); | 93 ASSERT(key != kUnsetThreadLocalKey); |
| 88 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); | 94 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); |
| 89 if (!result) { | 95 if (!result) { |
| 90 FATAL("TlsSetValue failed"); | 96 FATAL("TlsSetValue failed"); |
| 91 } | 97 } |
| 92 } | 98 } |
| 93 | 99 |
| 94 | 100 |
| 95 Mutex::Mutex() { | 101 Mutex::Mutex() { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 void Monitor::NotifyAll() { | 329 void Monitor::NotifyAll() { |
| 324 // If one of the objects in the list of waiters wakes because of a | 330 // If one of the objects in the list of waiters wakes because of a |
| 325 // timeout before we signal it, that object will get an extra | 331 // timeout before we signal it, that object will get an extra |
| 326 // signal. This will be treated as a spurious wake-up and is OK | 332 // signal. This will be treated as a spurious wake-up and is OK |
| 327 // since all uses of monitors should recheck the condition after a | 333 // since all uses of monitors should recheck the condition after a |
| 328 // Wait. | 334 // Wait. |
| 329 data_.SignalAndRemoveAllWaiters(); | 335 data_.SignalAndRemoveAllWaiters(); |
| 330 } | 336 } |
| 331 | 337 |
| 332 } // namespace dart | 338 } // namespace dart |
| OLD | NEW |