| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void initializeThreading() { | 136 void initializeThreading() { |
| 137 // This should only be called once. | 137 // This should only be called once. |
| 138 WTFThreadData::initialize(); | 138 WTFThreadData::initialize(); |
| 139 | 139 |
| 140 initializeDates(); | 140 initializeDates(); |
| 141 // Force initialization of static DoubleToStringConverter converter variable | 141 // Force initialization of static DoubleToStringConverter converter variable |
| 142 // inside EcmaScriptConverter function while we are in single thread mode. | 142 // inside EcmaScriptConverter function while we are in single thread mode. |
| 143 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); | 143 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 namespace { |
| 147 ThreadSpecificKey s_currentThreadKey; |
| 148 bool s_currentThreadKeyInitialized = false; |
| 149 } // namespace |
| 150 |
| 151 void initializeCurrentThread() { |
| 152 DCHECK(!s_currentThreadKeyInitialized); |
| 153 threadSpecificKeyCreate(&s_currentThreadKey, [](void*) {}); |
| 154 s_currentThreadKeyInitialized = true; |
| 155 } |
| 156 |
| 146 ThreadIdentifier currentThread() { | 157 ThreadIdentifier currentThread() { |
| 147 return wtfThreadData().threadId(); | 158 static_assert(sizeof(ThreadIdentifier) <= sizeof(void*), |
| 159 "ThreadIdentifier must fit in a void*."); |
| 160 DCHECK(s_currentThreadKeyInitialized); |
| 161 void* value = threadSpecificGet(s_currentThreadKey); |
| 162 if (UNLIKELY(!value)) { |
| 163 value = reinterpret_cast<void*>(internal::currentThreadSyscall()); |
| 164 DCHECK(value); |
| 165 threadSpecificSet(s_currentThreadKey, value); |
| 166 } |
| 167 return reinterpret_cast<intptr_t>(threadSpecificGet(s_currentThreadKey)); |
| 148 } | 168 } |
| 149 | 169 |
| 150 MutexBase::MutexBase(bool recursive) { | 170 MutexBase::MutexBase(bool recursive) { |
| 151 m_mutex.m_recursionCount = 0; | 171 m_mutex.m_recursionCount = 0; |
| 152 InitializeCriticalSection(&m_mutex.m_internalMutex); | 172 InitializeCriticalSection(&m_mutex.m_internalMutex); |
| 153 } | 173 } |
| 154 | 174 |
| 155 MutexBase::~MutexBase() { | 175 MutexBase::~MutexBase() { |
| 156 DeleteCriticalSection(&m_mutex.m_internalMutex); | 176 DeleteCriticalSection(&m_mutex.m_internalMutex); |
| 157 } | 177 } |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 408 } |
| 389 | 409 |
| 390 void willCreateThread() { | 410 void willCreateThread() { |
| 391 s_threadCreated = true; | 411 s_threadCreated = true; |
| 392 } | 412 } |
| 393 #endif | 413 #endif |
| 394 | 414 |
| 395 } // namespace WTF | 415 } // namespace WTF |
| 396 | 416 |
| 397 #endif // OS(WIN) | 417 #endif // OS(WIN) |
| OLD | NEW |