OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. | 4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. | 118 // <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. |
119 #pragma pack(push, 8) | 119 #pragma pack(push, 8) |
120 typedef struct tagTHREADNAME_INFO { | 120 typedef struct tagTHREADNAME_INFO { |
121 DWORD dwType; // must be 0x1000 | 121 DWORD dwType; // must be 0x1000 |
122 LPCSTR szName; // pointer to name (in user addr space) | 122 LPCSTR szName; // pointer to name (in user addr space) |
123 DWORD dwThreadID; // thread ID (-1=caller thread) | 123 DWORD dwThreadID; // thread ID (-1=caller thread) |
124 DWORD dwFlags; // reserved for future use, must be zero | 124 DWORD dwFlags; // reserved for future use, must be zero |
125 } THREADNAME_INFO; | 125 } THREADNAME_INFO; |
126 #pragma pack(pop) | 126 #pragma pack(pop) |
127 | 127 |
128 static Mutex* atomicallyInitializedStaticMutex; | |
129 | |
130 namespace internal { | 128 namespace internal { |
131 | 129 |
132 ThreadIdentifier currentThreadSyscall() { | 130 ThreadIdentifier currentThreadSyscall() { |
133 return static_cast<ThreadIdentifier>(GetCurrentThreadId()); | 131 return static_cast<ThreadIdentifier>(GetCurrentThreadId()); |
134 } | 132 } |
135 | 133 |
136 } // namespace internal | 134 } // namespace internal |
137 | 135 |
138 void lockAtomicallyInitializedStaticMutex() { | |
139 DCHECK(atomicallyInitializedStaticMutex); | |
140 atomicallyInitializedStaticMutex->lock(); | |
141 } | |
142 | |
143 void unlockAtomicallyInitializedStaticMutex() { | |
144 atomicallyInitializedStaticMutex->unlock(); | |
145 } | |
146 | |
147 void initializeThreading() { | 136 void initializeThreading() { |
148 // This should only be called once. | 137 // This should only be called once. |
149 DCHECK(!atomicallyInitializedStaticMutex); | |
150 | |
151 WTFThreadData::initialize(); | 138 WTFThreadData::initialize(); |
152 | 139 |
153 atomicallyInitializedStaticMutex = new Mutex; | |
154 initializeDates(); | 140 initializeDates(); |
155 // Force initialization of static DoubleToStringConverter converter variable | 141 // Force initialization of static DoubleToStringConverter converter variable |
156 // inside EcmaScriptConverter function while we are in single thread mode. | 142 // inside EcmaScriptConverter function while we are in single thread mode. |
157 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); | 143 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); |
158 } | 144 } |
159 | 145 |
160 ThreadIdentifier currentThread() { | 146 ThreadIdentifier currentThread() { |
161 return wtfThreadData().threadId(); | 147 return wtfThreadData().threadId(); |
162 } | 148 } |
163 | 149 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // forever. | 376 // forever. |
391 if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0) | 377 if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0) |
392 return INFINITE; | 378 return INFINITE; |
393 | 379 |
394 return static_cast<DWORD>((absoluteTime - currentTime) * 1000.0); | 380 return static_cast<DWORD>((absoluteTime - currentTime) * 1000.0); |
395 } | 381 } |
396 | 382 |
397 #if DCHECK_IS_ON() | 383 #if DCHECK_IS_ON() |
398 static bool s_threadCreated = false; | 384 static bool s_threadCreated = false; |
399 | 385 |
400 bool isAtomicallyInitializedStaticMutexLockHeld() { | |
401 return atomicallyInitializedStaticMutex && | |
402 atomicallyInitializedStaticMutex->locked(); | |
403 } | |
404 | |
405 bool isBeforeThreadCreated() { | 386 bool isBeforeThreadCreated() { |
406 return !s_threadCreated; | 387 return !s_threadCreated; |
407 } | 388 } |
408 | 389 |
409 void willCreateThread() { | 390 void willCreateThread() { |
410 s_threadCreated = true; | 391 s_threadCreated = true; |
411 } | 392 } |
412 #endif | 393 #endif |
413 | 394 |
414 } // namespace WTF | 395 } // namespace WTF |
415 | 396 |
416 #endif // OS(WIN) | 397 #endif // OS(WIN) |
OLD | NEW |