| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return syscall(__NR_gettid); | 68 return syscall(__NR_gettid); |
| 69 #elif OS(ANDROID) | 69 #elif OS(ANDROID) |
| 70 return gettid(); | 70 return gettid(); |
| 71 #else | 71 #else |
| 72 return reinterpret_cast<uintptr_t>(pthread_self()); | 72 return reinterpret_cast<uintptr_t>(pthread_self()); |
| 73 #endif | 73 #endif |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace internal | 76 } // namespace internal |
| 77 | 77 |
| 78 static Mutex* atomicallyInitializedStaticMutex; | |
| 79 | |
| 80 void initializeThreading() { | 78 void initializeThreading() { |
| 81 // This should only be called once. | 79 // This should only be called once. |
| 82 DCHECK(!atomicallyInitializedStaticMutex); | |
| 83 | |
| 84 WTFThreadData::initialize(); | 80 WTFThreadData::initialize(); |
| 85 | 81 |
| 86 atomicallyInitializedStaticMutex = new Mutex; | |
| 87 initializeDates(); | 82 initializeDates(); |
| 88 // Force initialization of static DoubleToStringConverter converter variable | 83 // Force initialization of static DoubleToStringConverter converter variable |
| 89 // inside EcmaScriptConverter function while we are in single thread mode. | 84 // inside EcmaScriptConverter function while we are in single thread mode. |
| 90 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); | 85 double_conversion::DoubleToStringConverter::EcmaScriptConverter(); |
| 91 } | 86 } |
| 92 | 87 |
| 93 void lockAtomicallyInitializedStaticMutex() { | |
| 94 DCHECK(atomicallyInitializedStaticMutex); | |
| 95 atomicallyInitializedStaticMutex->lock(); | |
| 96 } | |
| 97 | |
| 98 void unlockAtomicallyInitializedStaticMutex() { | |
| 99 atomicallyInitializedStaticMutex->unlock(); | |
| 100 } | |
| 101 | |
| 102 ThreadIdentifier currentThread() { | 88 ThreadIdentifier currentThread() { |
| 103 return wtfThreadData().threadId(); | 89 return wtfThreadData().threadId(); |
| 104 } | 90 } |
| 105 | 91 |
| 106 MutexBase::MutexBase(bool recursive) { | 92 MutexBase::MutexBase(bool recursive) { |
| 107 pthread_mutexattr_t attr; | 93 pthread_mutexattr_t attr; |
| 108 pthread_mutexattr_init(&attr); | 94 pthread_mutexattr_init(&attr); |
| 109 pthread_mutexattr_settype( | 95 pthread_mutexattr_settype( |
| 110 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); | 96 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); |
| 111 | 97 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 212 } |
| 227 | 213 |
| 228 void ThreadCondition::broadcast() { | 214 void ThreadCondition::broadcast() { |
| 229 int result = pthread_cond_broadcast(&m_condition); | 215 int result = pthread_cond_broadcast(&m_condition); |
| 230 DCHECK_EQ(result, 0); | 216 DCHECK_EQ(result, 0); |
| 231 } | 217 } |
| 232 | 218 |
| 233 #if DCHECK_IS_ON() | 219 #if DCHECK_IS_ON() |
| 234 static bool s_threadCreated = false; | 220 static bool s_threadCreated = false; |
| 235 | 221 |
| 236 bool isAtomicallyInitializedStaticMutexLockHeld() { | |
| 237 return atomicallyInitializedStaticMutex && | |
| 238 atomicallyInitializedStaticMutex->locked(); | |
| 239 } | |
| 240 | |
| 241 bool isBeforeThreadCreated() { | 222 bool isBeforeThreadCreated() { |
| 242 return !s_threadCreated; | 223 return !s_threadCreated; |
| 243 } | 224 } |
| 244 | 225 |
| 245 void willCreateThread() { | 226 void willCreateThread() { |
| 246 s_threadCreated = true; | 227 s_threadCreated = true; |
| 247 } | 228 } |
| 248 #endif | 229 #endif |
| 249 | 230 |
| 250 } // namespace WTF | 231 } // namespace WTF |
| 251 | 232 |
| 252 #endif // OS(POSIX) | 233 #endif // OS(POSIX) |
| OLD | NEW |