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 "platform/thread.h" | 8 #include "platform/thread.h" |
9 | 9 |
10 #include <process.h> // NOLINT | 10 #include <process.h> // NOLINT |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 intptr_t Thread::GetMaxStackSize() { | 89 intptr_t Thread::GetMaxStackSize() { |
90 const int kStackSize = (128 * kWordSize * KB); | 90 const int kStackSize = (128 * kWordSize * KB); |
91 return kStackSize; | 91 return kStackSize; |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 ThreadId Thread::GetCurrentThreadId() { | |
96 return GetCurrentThread(); | |
97 } | |
98 | |
99 | |
100 void Thread::GetThreadCPUUsage(int64_t* cpu_usage) { | |
101 ASSERT(cpu_usage != NULL); | |
102 *cpu_usage = 0; | |
siva
2013/10/28 05:19:21
UNIMPLEMENTED();
Cutch
2013/11/04 20:36:05
Done, but will be implemented soon.
| |
103 } | |
104 | |
105 | |
95 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { | 106 void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
96 ASSERT(key != kUnsetThreadLocalKey); | 107 ASSERT(key != kUnsetThreadLocalKey); |
97 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); | 108 BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); |
98 if (!result) { | 109 if (!result) { |
99 FATAL1("TlsSetValue failed %d", GetLastError()); | 110 FATAL1("TlsSetValue failed %d", GetLastError()); |
100 } | 111 } |
101 } | 112 } |
102 | 113 |
103 | 114 |
104 Mutex::Mutex() { | 115 Mutex::Mutex() { |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 } | 342 } |
332 } | 343 } |
333 | 344 |
334 // Reacquire the monitor critical section before continuing. | 345 // Reacquire the monitor critical section before continuing. |
335 EnterCriticalSection(&data_.cs_); | 346 EnterCriticalSection(&data_.cs_); |
336 | 347 |
337 return retval; | 348 return retval; |
338 } | 349 } |
339 | 350 |
340 | 351 |
352 Monitor::WaitResult Monitor::WaitMicros(int64_t micros) { | |
353 // TODO(johnmccutchan): Investigate sub-millisecond sleep times on Windows. | |
354 int64_t millis = micros / kMicrosecondsPerMillisecond; | |
355 if ((millis * kMicrosecondsPerMillisecond) < micros) { | |
356 // We've been asked to sleep for a fraction of a millisecond, | |
357 // this isn't supported on Windows. Bumps milliseconds up by one | |
358 // so that we never return too early. We likely return late though. | |
359 millis += 1; | |
360 } | |
361 return Wait(millis); | |
362 } | |
363 | |
364 | |
341 void Monitor::Notify() { | 365 void Monitor::Notify() { |
342 data_.SignalAndRemoveFirstWaiter(); | 366 data_.SignalAndRemoveFirstWaiter(); |
343 } | 367 } |
344 | 368 |
345 | 369 |
346 void Monitor::NotifyAll() { | 370 void Monitor::NotifyAll() { |
347 // If one of the objects in the list of waiters wakes because of a | 371 // If one of the objects in the list of waiters wakes because of a |
348 // timeout before we signal it, that object will get an extra | 372 // timeout before we signal it, that object will get an extra |
349 // signal. This will be treated as a spurious wake-up and is OK | 373 // signal. This will be treated as a spurious wake-up and is OK |
350 // since all uses of monitors should recheck the condition after a | 374 // since all uses of monitors should recheck the condition after a |
351 // Wait. | 375 // Wait. |
352 data_.SignalAndRemoveAllWaiters(); | 376 data_.SignalAndRemoveAllWaiters(); |
353 } | 377 } |
354 | 378 |
355 } // namespace dart | 379 } // namespace dart |
356 | 380 |
357 #endif // defined(TARGET_OS_WINDOWS) | 381 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |