| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; | 128 static Mutex* atomicallyInitializedStaticMutex; |
| 129 | 129 |
| 130 namespace internal { |
| 131 |
| 132 ThreadIdentifier currentThreadSyscall() { |
| 133 return static_cast<ThreadIdentifier>(GetCurrentThreadId()); |
| 134 } |
| 135 |
| 136 } // namespace internal |
| 137 |
| 130 void lockAtomicallyInitializedStaticMutex() { | 138 void lockAtomicallyInitializedStaticMutex() { |
| 131 DCHECK(atomicallyInitializedStaticMutex); | 139 DCHECK(atomicallyInitializedStaticMutex); |
| 132 atomicallyInitializedStaticMutex->lock(); | 140 atomicallyInitializedStaticMutex->lock(); |
| 133 } | 141 } |
| 134 | 142 |
| 135 void unlockAtomicallyInitializedStaticMutex() { | 143 void unlockAtomicallyInitializedStaticMutex() { |
| 136 atomicallyInitializedStaticMutex->unlock(); | 144 atomicallyInitializedStaticMutex->unlock(); |
| 137 } | 145 } |
| 138 | 146 |
| 139 void initializeThreading() { | 147 void initializeThreading() { |
| 140 // This should only be called once. | 148 // This should only be called once. |
| 141 DCHECK(!atomicallyInitializedStaticMutex); | 149 DCHECK(!atomicallyInitializedStaticMutex); |
| 142 | 150 |
| 143 // StringImpl::empty() does not construct its static string in a threadsafe | 151 // StringImpl::empty() does not construct its static string in a threadsafe |
| 144 // fashion, so ensure it has been initialized from here. | 152 // fashion, so ensure it has been initialized from here. |
| 145 StringImpl::empty(); | 153 StringImpl::empty(); |
| 146 StringImpl::empty16Bit(); | 154 StringImpl::empty16Bit(); |
| 147 atomicallyInitializedStaticMutex = new Mutex; | 155 atomicallyInitializedStaticMutex = new Mutex; |
| 148 wtfThreadData(); | 156 wtfThreadData(); |
| 149 initializeDates(); | 157 initializeDates(); |
| 150 // Force initialization of static DoubleToStringConverter converter variable | 158 // Force initialization of static DoubleToStringConverter converter variable |
| 151 // inside EcmaScriptConverter function while we are in single thread mode. | 159 // inside EcmaScriptConverter function while we are in single thread mode. |
| 152 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); | 160 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); |
| 153 } | 161 } |
| 154 | 162 |
| 155 ThreadIdentifier currentThread() { | 163 ThreadIdentifier currentThread() { |
| 156 return static_cast<ThreadIdentifier>(GetCurrentThreadId()); | 164 return internal::currentThreadSyscall(); |
| 157 } | 165 } |
| 158 | 166 |
| 159 MutexBase::MutexBase(bool recursive) { | 167 MutexBase::MutexBase(bool recursive) { |
| 160 m_mutex.m_recursionCount = 0; | 168 m_mutex.m_recursionCount = 0; |
| 161 InitializeCriticalSection(&m_mutex.m_internalMutex); | 169 InitializeCriticalSection(&m_mutex.m_internalMutex); |
| 162 } | 170 } |
| 163 | 171 |
| 164 MutexBase::~MutexBase() { | 172 MutexBase::~MutexBase() { |
| 165 DeleteCriticalSection(&m_mutex.m_internalMutex); | 173 DeleteCriticalSection(&m_mutex.m_internalMutex); |
| 166 } | 174 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 410 } |
| 403 | 411 |
| 404 void willCreateThread() { | 412 void willCreateThread() { |
| 405 s_threadCreated = true; | 413 s_threadCreated = true; |
| 406 } | 414 } |
| 407 #endif | 415 #endif |
| 408 | 416 |
| 409 } // namespace WTF | 417 } // namespace WTF |
| 410 | 418 |
| 411 #endif // OS(WIN) | 419 #endif // OS(WIN) |
| OLD | NEW |