| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
| 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 void initializeThreading() { | 78 void initializeThreading() { |
| 79 // This should only be called once. | 79 // This should only be called once. |
| 80 WTFThreadData::initialize(); | 80 WTFThreadData::initialize(); |
| 81 | 81 |
| 82 initializeDates(); | 82 initializeDates(); |
| 83 // Force initialization of static DoubleToStringConverter converter variable | 83 // Force initialization of static DoubleToStringConverter converter variable |
| 84 // inside EcmaScriptConverter function while we are in single thread mode. | 84 // inside EcmaScriptConverter function while we are in single thread mode. |
| 85 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); | 85 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 namespace { |
| 89 ThreadSpecificKey s_currentThreadKey; |
| 90 } // namespace |
| 91 |
| 92 void initializeCurrentThread() { |
| 93 threadSpecificKeyCreate(&s_currentThreadKey, [](void*) {}); |
| 94 } |
| 95 |
| 88 ThreadIdentifier currentThread() { | 96 ThreadIdentifier currentThread() { |
| 89 return wtfThreadData().threadId(); | 97 static_assert(sizeof(ThreadIdentifier) <= sizeof(void*), |
| 98 "ThreadIdentifier must fit in a void*."); |
| 99 void* value = threadSpecificGet(s_currentThreadKey); |
| 100 if (UNLIKELY(!value)) { |
| 101 value = reinterpret_cast<void*>( |
| 102 static_cast<intptr_t>(internal::currentThreadSyscall())); |
| 103 DCHECK(value); |
| 104 threadSpecificSet(s_currentThreadKey, value); |
| 105 } |
| 106 return reinterpret_cast<intptr_t>(threadSpecificGet(s_currentThreadKey)); |
| 90 } | 107 } |
| 91 | 108 |
| 92 MutexBase::MutexBase(bool recursive) { | 109 MutexBase::MutexBase(bool recursive) { |
| 93 pthread_mutexattr_t attr; | 110 pthread_mutexattr_t attr; |
| 94 pthread_mutexattr_init(&attr); | 111 pthread_mutexattr_init(&attr); |
| 95 pthread_mutexattr_settype( | 112 pthread_mutexattr_settype( |
| 96 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); | 113 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); |
| 97 | 114 |
| 98 int result = pthread_mutex_init(&m_mutex.m_internalMutex, &attr); | 115 int result = pthread_mutex_init(&m_mutex.m_internalMutex, &attr); |
| 99 DCHECK_EQ(result, 0); | 116 DCHECK_EQ(result, 0); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 241 } |
| 225 | 242 |
| 226 void willCreateThread() { | 243 void willCreateThread() { |
| 227 s_threadCreated = true; | 244 s_threadCreated = true; |
| 228 } | 245 } |
| 229 #endif | 246 #endif |
| 230 | 247 |
| 231 } // namespace WTF | 248 } // namespace WTF |
| 232 | 249 |
| 233 #endif // OS(POSIX) | 250 #endif // OS(POSIX) |
| OLD | NEW |