Changeset 188642 in webkit
- Timestamp:
- Aug 19, 2015 11:18:19 AM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 67 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r188631 r188642 1 2015-08-18 Filip Pizlo <fpizlo@apple.com> 2 3 Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition 4 https://bugs.webkit.org/show_bug.cgi?id=148140 5 6 Reviewed by Geoffrey Garen. 7 8 * inspector/remote/RemoteInspector.h: 9 * inspector/remote/RemoteInspector.mm: 10 (Inspector::RemoteInspector::registerDebuggable): 11 (Inspector::RemoteInspector::unregisterDebuggable): 12 (Inspector::RemoteInspector::updateDebuggable): 13 (Inspector::RemoteInspector::updateDebuggableAutomaticInspectCandidate): 14 (Inspector::RemoteInspector::sendMessageToRemoteFrontend): 15 (Inspector::RemoteInspector::setupFailed): 16 (Inspector::RemoteInspector::setupCompleted): 17 (Inspector::RemoteInspector::start): 18 (Inspector::RemoteInspector::stop): 19 (Inspector::RemoteInspector::setupXPCConnectionIfNeeded): 20 (Inspector::RemoteInspector::setParentProcessInformation): 21 (Inspector::RemoteInspector::xpcConnectionReceivedMessage): 22 (Inspector::RemoteInspector::xpcConnectionFailed): 23 (Inspector::RemoteInspector::pushListingSoon): 24 (Inspector::RemoteInspector::receivedIndicateMessage): 25 (Inspector::RemoteInspector::receivedProxyApplicationSetupMessage): 26 * inspector/remote/RemoteInspectorXPCConnection.h: 27 * inspector/remote/RemoteInspectorXPCConnection.mm: 28 (Inspector::RemoteInspectorXPCConnection::close): 29 (Inspector::RemoteInspectorXPCConnection::closeFromMessage): 30 (Inspector::RemoteInspectorXPCConnection::deserializeMessage): 31 (Inspector::RemoteInspectorXPCConnection::handleEvent): 32 1 33 2015-08-18 Joseph Pecoraro <pecoraro@apple.com> 2 34 -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h
r179409 r188642 32 32 #import <wtf/Forward.h> 33 33 #import <wtf/HashMap.h> 34 #import <wtf/Lock.h> 34 35 #import <wtf/RetainPtr.h> 35 36 … … 109 110 // So lock access to all maps and state as they can change 110 111 // from any thread. 111 std::mutexm_mutex;112 Lock m_mutex; 112 113 113 114 HashMap<unsigned, std::pair<RemoteInspectorDebuggable*, RemoteInspectorDebuggableInfo>> m_debuggableMap; -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm
r183590 r188642 132 132 void RemoteInspector::registerDebuggable(RemoteInspectorDebuggable* debuggable) 133 133 { 134 std::lock_guard< std::mutex> lock(m_mutex);134 std::lock_guard<Lock> lock(m_mutex); 135 135 136 136 unsigned identifier = nextAvailableIdentifier(); … … 146 146 void RemoteInspector::unregisterDebuggable(RemoteInspectorDebuggable* debuggable) 147 147 { 148 std::lock_guard< std::mutex> lock(m_mutex);148 std::lock_guard<Lock> lock(m_mutex); 149 149 150 150 unsigned identifier = debuggable->identifier(); … … 164 164 void RemoteInspector::updateDebuggable(RemoteInspectorDebuggable* debuggable) 165 165 { 166 std::lock_guard< std::mutex> lock(m_mutex);166 std::lock_guard<Lock> lock(m_mutex); 167 167 168 168 unsigned identifier = debuggable->identifier(); … … 179 179 { 180 180 { 181 std::lock_guard< std::mutex> lock(m_mutex);181 std::lock_guard<Lock> lock(m_mutex); 182 182 183 183 unsigned identifier = debuggable->identifier(); … … 214 214 // In case debuggers fail to respond, or we cannot connect to webinspectord, automatically continue after a short period of time. 215 215 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.8 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 216 std::lock_guard< std::mutex> lock(m_mutex);216 std::lock_guard<Lock> lock(m_mutex); 217 217 if (m_automaticInspectionCandidateIdentifier == identifier) { 218 218 LOG_ERROR("Skipping Automatic Inspection Candidate with pageId(%u) because we failed to receive a response in time.", m_automaticInspectionCandidateIdentifier); … … 225 225 226 226 { 227 std::lock_guard< std::mutex> lock(m_mutex);227 std::lock_guard<Lock> lock(m_mutex); 228 228 229 229 ASSERT(m_automaticInspectionCandidateIdentifier); … … 246 246 void RemoteInspector::sendMessageToRemoteFrontend(unsigned identifier, const String& message) 247 247 { 248 std::lock_guard< std::mutex> lock(m_mutex);248 std::lock_guard<Lock> lock(m_mutex); 249 249 250 250 if (!m_xpcConnection) … … 266 266 void RemoteInspector::setupFailed(unsigned identifier) 267 267 { 268 std::lock_guard< std::mutex> lock(m_mutex);268 std::lock_guard<Lock> lock(m_mutex); 269 269 270 270 m_connectionMap.remove(identifier); … … 280 280 void RemoteInspector::setupCompleted(unsigned identifier) 281 281 { 282 std::lock_guard< std::mutex> lock(m_mutex);282 std::lock_guard<Lock> lock(m_mutex); 283 283 284 284 if (identifier == m_automaticInspectionCandidateIdentifier) … … 294 294 void RemoteInspector::start() 295 295 { 296 std::lock_guard< std::mutex> lock(m_mutex);296 std::lock_guard<Lock> lock(m_mutex); 297 297 298 298 if (m_enabled) … … 316 316 void RemoteInspector::stop() 317 317 { 318 std::lock_guard< std::mutex> lock(m_mutex);318 std::lock_guard<Lock> lock(m_mutex); 319 319 320 320 stopInternal(StopSource::API); … … 356 356 void RemoteInspector::setupXPCConnectionIfNeeded() 357 357 { 358 std::lock_guard< std::mutex> lock(m_mutex);358 std::lock_guard<Lock> lock(m_mutex); 359 359 360 360 if (m_xpcConnection) … … 381 381 void RemoteInspector::setParentProcessInformation(pid_t pid, RetainPtr<CFDataRef> auditData) 382 382 { 383 std::lock_guard< std::mutex> lock(m_mutex);383 std::lock_guard<Lock> lock(m_mutex); 384 384 385 385 if (m_parentProcessIdentifier || m_parentProcessAuditData) … … 397 397 void RemoteInspector::xpcConnectionReceivedMessage(RemoteInspectorXPCConnection*, NSString *messageName, NSDictionary *userInfo) 398 398 { 399 std::lock_guard< std::mutex> lock(m_mutex);399 std::lock_guard<Lock> lock(m_mutex); 400 400 401 401 if ([messageName isEqualToString:WIRPermissionDenied]) { … … 428 428 void RemoteInspector::xpcConnectionFailed(RemoteInspectorXPCConnection* connection) 429 429 { 430 std::lock_guard< std::mutex> lock(m_mutex);430 std::lock_guard<Lock> lock(m_mutex); 431 431 432 432 ASSERT(connection == m_xpcConnection); … … 523 523 m_pushScheduled = true; 524 524 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 525 std::lock_guard< std::mutex> lock(m_mutex);525 std::lock_guard<Lock> lock(m_mutex); 526 526 if (m_pushScheduled) 527 527 pushListingNow(); … … 650 650 RemoteInspectorDebuggable* debuggable = nullptr; 651 651 { 652 std::lock_guard< std::mutex> lock(m_mutex);652 std::lock_guard<Lock> lock(m_mutex); 653 653 654 654 auto it = m_debuggableMap.find(identifier); … … 673 673 m_shouldSendParentProcessInformation = true; 674 674 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 675 std::lock_guard< std::mutex> lock(m_mutex);675 std::lock_guard<Lock> lock(m_mutex); 676 676 if (m_shouldSendParentProcessInformation) 677 677 stopInternal(StopSource::XPCMessage); -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h
r174220 r188642 30 30 31 31 #import <dispatch/dispatch.h> 32 #import < mutex>32 #import <wtf/Lock.h> 33 33 #import <wtf/ThreadSafeRefCounted.h> 34 34 #import <wtf/spi/darwin/XPCSPI.h> … … 63 63 // We handle XPC events on the queue, but a client may call close() on any queue. 64 64 // We make sure that m_client is thread safe and immediately cleared in close(). 65 std::mutexm_mutex;65 Lock m_mutex; 66 66 67 67 xpc_connection_t m_connection; -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.mm
r181992 r188642 30 30 31 31 #import <Foundation/Foundation.h> 32 #import <mutex> 32 33 #import <wtf/Assertions.h> 34 #import <wtf/Lock.h> 33 35 #import <wtf/Ref.h> 34 36 #import <wtf/RetainPtr.h> … … 80 82 void RemoteInspectorXPCConnection::close() 81 83 { 82 std::lock_guard< std::mutex> lock(m_mutex);84 std::lock_guard<Lock> lock(m_mutex); 83 85 closeFromMessage(); 84 86 } … … 90 92 91 93 dispatch_async(m_queue, ^{ 92 std::lock_guard< std::mutex> lock(m_mutex);94 std::lock_guard<Lock> lock(m_mutex); 93 95 // This will trigger one last XPC_ERROR_CONNECTION_INVALID event on the queue and deref us. 94 96 closeOnQueue(); … … 117 119 xpc_object_t xpcDictionary = xpc_dictionary_get_value(object, RemoteInspectorXPCConnectionSerializedMessageKey); 118 120 if (!xpcDictionary || xpc_get_type(xpcDictionary) != XPC_TYPE_DICTIONARY) { 119 std::lock_guard< std::mutex> lock(m_mutex);121 std::lock_guard<Lock> lock(m_mutex); 120 122 if (m_client) 121 123 m_client->xpcConnectionUnhandledMessage(this, object); … … 132 134 if (xpc_get_type(object) == XPC_TYPE_ERROR) { 133 135 { 134 std::lock_guard< std::mutex> lock(m_mutex);136 std::lock_guard<Lock> lock(m_mutex); 135 137 if (m_client) 136 138 m_client->xpcConnectionFailed(this); … … 155 157 NSString *message = [dataDictionary objectForKey:RemoteInspectorXPCConnectionMessageNameKey]; 156 158 NSDictionary *userInfo = [dataDictionary objectForKey:RemoteInspectorXPCConnectionUserInfoKey]; 157 std::lock_guard< std::mutex> lock(m_mutex);159 std::lock_guard<Lock> lock(m_mutex); 158 160 if (m_client) 159 161 m_client->xpcConnectionReceivedMessage(this, message, userInfo); -
trunk/Source/WTF/ChangeLog
r188633 r188642 1 2015-08-18 Filip Pizlo <fpizlo@apple.com> 2 3 Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition 4 https://bugs.webkit.org/show_bug.cgi?id=148140 5 6 Reviewed by Geoffrey Garen. 7 8 Also beef up Condition by giving it a StaticCondition variant. 9 10 * wtf/Condition.h: 11 (WTF::ConditionBase::notifyAll): 12 (WTF::ConditionBase::waitForSecondsImpl): 13 (WTF::ConditionBase::absoluteFromRelative): 14 (WTF::Condition::Condition): 15 (WTF::Condition::notifyAll): Deleted. 16 (WTF::Condition::waitForSecondsImpl): Deleted. 17 (WTF::Condition::absoluteFromRelative): Deleted. 18 * wtf/CryptographicallyRandomNumber.cpp: 19 * wtf/HashTable.cpp: 20 (WTF::HashTableStats::recordCollisionAtCount): 21 (WTF::HashTableStats::dumpStats): 22 (WTF::hashTableStatsMutex): Deleted. 23 * wtf/HashTable.h: 24 (WTF::KeyTraits>::HashTable): 25 (WTF::KeyTraits>::invalidateIterators): 26 (WTF::addIterator): 27 (WTF::removeIterator): 28 * wtf/Lock.h: 29 * wtf/MainThread.cpp: 30 (WTF::functionQueue): 31 (WTF::dispatchFunctionsFromMainThread): 32 (WTF::callOnMainThread): 33 (WTF::cancelCallOnMainThread): 34 (WTF::mainThreadFunctionQueueMutex): Deleted. 35 * wtf/StackStats.cpp: 36 (WTF::StackStats::PerThreadStats::PerThreadStats): 37 (WTF::StackStats::CheckPoint::CheckPoint): 38 (WTF::StackStats::CheckPoint::~CheckPoint): 39 (WTF::StackStats::probe): 40 (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint): 41 (WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint): 42 (WTF::StackStats::initialize): Deleted. 43 * wtf/StackStats.h: 44 (WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint): 45 (WTF::StackStats::probe): 46 (WTF::StackStats::initialize): Deleted. 47 * wtf/ThreadingPthreads.cpp: 48 (WTF::initializeThreading): 49 * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: 50 (WTF::callOnMainThread): 51 (WTF::lockAtomicallyInitializedStaticMutex): 52 (WTF::unlockAtomicallyInitializedStaticMutex): 53 (WTF::atomicallyInitializedStaticMutex): Deleted. 54 * wtf/text/StringView.cpp: 55 (WTF::StringView::UnderlyingString::UnderlyingString): 56 (WTF::underlyingStrings): 57 (WTF::StringView::invalidate): 58 (WTF::StringView::adoptUnderlyingString): 59 (WTF::StringView::setUnderlyingString): 60 (WTF::underlyingStringsMutex): Deleted. 61 * wtf/unicode/icu/CollatorICU.cpp: 62 (WTF::Collator::Collator): 63 (WTF::Collator::~Collator): 64 (WTF::cachedCollatorMutex): Deleted. 65 1 66 2015-08-18 Zan Dobersek <zdobersek@igalia.com> 2 67 -
trunk/Source/WTF/wtf/Condition.h
r188605 r188642 29 29 #include <chrono> 30 30 #include <functional> 31 #include <mutex>32 31 #include <wtf/CurrentTime.h> 32 #include <wtf/Noncopyable.h> 33 33 #include <wtf/ParkingLot.h> 34 34 35 35 namespace WTF { 36 36 37 class Condition { 38 public: 37 // This is a condition variable that is suitable for use with any lock-like object, including 38 // our own WTF::Lock. It features standard wait()/notifyOne()/notifyAll() methods in addition to 39 // a variety of wait-with-timeout methods. This includes methods that use WTF's own notion of 40 // time, like wall-clock time (i.e. currentTime()) and monotonic time (i.e. 41 // monotonicallyIncreasingTime()). This is a very efficient condition variable. It only requires 42 // one byte of memory. notifyOne() and notifyAll() require just a load and branch for the fast 43 // case where no thread is waiting. This condition variable, when used with WTF::Lock, can 44 // outperform a system condition variable and lock by up to 58x. 45 46 // This is a struct without a constructor or destructor so that it can be statically initialized. 47 // Use Lock in instance variables. 48 struct ConditionBase { 39 49 typedef ParkingLot::Clock Clock; 40 50 41 Condition()42 {43 m_hasWaiters.store(false);44 }45 46 51 // Wait on a parking queue while releasing the given lock. It will unlock the lock just before 47 52 // parking, and relock it upon wakeup. Returns true if we woke up due to some call to … … 173 178 } 174 179 175 pr ivate:180 protected: 176 181 template<typename LockType> 177 182 bool waitForSecondsImpl(LockType& lock, double relativeTimeoutSeconds) … … 225 230 226 231 Atomic<bool> m_hasWaiters; 232 }; 233 234 class Condition : public ConditionBase { 235 WTF_MAKE_NONCOPYABLE(Condition); 236 public: 237 Condition() 238 { 239 m_hasWaiters.store(false); 240 } 227 241 }; 228 242 243 typedef ConditionBase StaticCondition; 244 229 245 } // namespace WTF 230 246 231 247 using WTF::Condition; 248 using WTF::StaticCondition; 232 249 233 250 #endif // WTF_Condition_h -
trunk/Source/WTF/wtf/CryptographicallyRandomNumber.cpp
r162935 r188642 34 34 #include "OSRandomSource.h" 35 35 #include <mutex> 36 #include <wtf/Lock.h> 36 37 37 38 namespace WTF { … … 65 66 ARC4Stream m_stream; 66 67 int m_count; 67 std::mutexm_mutex;68 Lock m_mutex; 68 69 }; 69 70 … … 137 138 uint32_t ARC4RandomNumberGenerator::randomNumber() 138 139 { 139 std::lock_guard< std::mutex> lock(m_mutex);140 std::lock_guard<Lock> lock(m_mutex); 140 141 141 142 m_count -= 4; … … 146 147 void ARC4RandomNumberGenerator::randomValues(void* buffer, size_t length) 147 148 { 148 std::lock_guard< std::mutex> lock(m_mutex);149 std::lock_guard<Lock> lock(m_mutex); 149 150 150 151 unsigned char* result = reinterpret_cast<unsigned char*>(buffer); -
trunk/Source/WTF/wtf/HashTable.cpp
r162774 r188642 37 37 unsigned HashTableStats::maxCollisions; 38 38 39 static std::mutex& hashTableStatsMutex() 40 { 41 static std::once_flag onceFlag; 42 static std::mutex* mutex; 43 std::call_once(onceFlag, []{ 44 mutex = std::make_unique<std::mutex>().release(); 45 }); 46 47 return *mutex; 48 } 39 static StaticLock hashTableStatsMutex; 49 40 50 41 void HashTableStats::recordCollisionAtCount(unsigned count) 51 42 { 52 std::lock_guard< std::mutex> lock(hashTableStatsMutex());43 std::lock_guard<StaticLock> lock(hashTableStatsMutex); 53 44 54 45 if (count > maxCollisions) … … 60 51 void HashTableStats::dumpStats() 61 52 { 62 std::lock_guard< std::mutex> lock(hashTableStatsMutex());53 std::lock_guard<StaticLock> lock(hashTableStatsMutex); 63 54 64 55 dataLogF("\nWTF::HashTable statistics\n\n"); -
trunk/Source/WTF/wtf/HashTable.h
r187733 r188642 1 1 /* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012, 2015 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 David Levin <levin@chromium.org> 4 4 * … … 31 31 #include <wtf/FastMalloc.h> 32 32 #include <wtf/HashTraits.h> 33 #include <wtf/Lock.h> 33 34 #include <wtf/MathExtras.h> 34 35 #include <wtf/StdLibExtras.h> … … 487 488 mutable const_iterator* m_iterators; 488 489 // Use std::unique_ptr so HashTable can still be memmove'd or memcpy'ed. 489 mutable std::unique_ptr< std::mutex> m_mutex;490 mutable std::unique_ptr<Lock> m_mutex; 490 491 #endif 491 492 … … 543 544 #if CHECK_HASHTABLE_ITERATORS 544 545 , m_iterators(0) 545 , m_mutex(std::make_unique< std::mutex>())546 , m_mutex(std::make_unique<Lock>()) 546 547 #endif 547 548 #if DUMP_HASHTABLE_STATS_PER_TABLE … … 1219 1220 #if CHECK_HASHTABLE_ITERATORS 1220 1221 , m_iterators(nullptr) 1221 , m_mutex(std::make_unique< std::mutex>())1222 , m_mutex(std::make_unique<Lock>()) 1222 1223 #endif 1223 1224 #if DUMP_HASHTABLE_STATS_PER_TABLE … … 1277 1278 #if CHECK_HASHTABLE_ITERATORS 1278 1279 : m_iterators(nullptr) 1279 , m_mutex(std::make_unique< std::mutex>())1280 , m_mutex(std::make_unique<Lock>()) 1280 1281 #endif 1281 1282 { … … 1357 1358 void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::invalidateIterators() 1358 1359 { 1359 std::lock_guard< std::mutex> lock(*m_mutex);1360 std::lock_guard<Lock> lock(*m_mutex); 1360 1361 const_iterator* next; 1361 1362 for (const_iterator* p = m_iterators; p; p = next) { … … 1379 1380 it->m_next = 0; 1380 1381 } else { 1381 std::lock_guard< std::mutex> lock(*table->m_mutex);1382 std::lock_guard<Lock> lock(*table->m_mutex); 1382 1383 ASSERT(table->m_iterators != it); 1383 1384 it->m_next = table->m_iterators; … … 1398 1399 ASSERT(!it->m_previous); 1399 1400 } else { 1400 std::lock_guard< std::mutex> lock(*it->m_table->m_mutex);1401 std::lock_guard<Lock> lock(*it->m_table->m_mutex); 1401 1402 if (it->m_next) { 1402 1403 ASSERT(it->m_next->m_previous == it); -
trunk/Source/WTF/wtf/Lock.h
r188499 r188642 126 126 } // namespace WTF 127 127 128 using WTF::StaticLock;129 128 using WTF::Lock; 130 129 using WTF::LockHolder; 130 using WTF::StaticLock; 131 131 132 132 #endif // WTF_Lock_h -
trunk/Source/WTF/wtf/MainThread.cpp
r183746 r188642 1 1 /* 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 #include "Threading.h" 36 36 #include <mutex> 37 #include <wtf/Lock.h> 37 38 #include <wtf/NeverDestroyed.h> 38 39 #include <wtf/ThreadSpecific.h> … … 70 71 #endif 71 72 72 static std::mutex& mainThreadFunctionQueueMutex() 73 { 74 static NeverDestroyed<std::mutex> mutex; 75 76 return mutex; 77 } 73 static StaticLock mainThreadFunctionQueueMutex; 78 74 79 75 static FunctionQueue& functionQueue() … … 95 91 mainThreadIdentifier = currentThread(); 96 92 97 mainThreadFunctionQueueMutex();98 93 initializeMainThreadPlatform(); 99 94 initializeGCThreads(); … … 106 101 static void initializeMainThreadOnce() 107 102 { 108 mainThreadFunctionQueueMutex();109 103 initializeMainThreadPlatform(); 110 104 } … … 118 112 static void initializeMainThreadToProcessMainThreadOnce() 119 113 { 120 mainThreadFunctionQueueMutex();121 114 initializeMainThreadToProcessMainThreadPlatform(); 122 115 } … … 157 150 while (true) { 158 151 { 159 std::lock_guard< std::mutex> lock(mainThreadFunctionQueueMutex());152 std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex); 160 153 if (!functionQueue().size()) 161 154 break; … … 181 174 bool needToSchedule = false; 182 175 { 183 std::lock_guard< std::mutex> lock(mainThreadFunctionQueueMutex());176 std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex); 184 177 needToSchedule = functionQueue().size() == 0; 185 178 functionQueue().append(FunctionWithContext(function, context)); … … 193 186 ASSERT(function); 194 187 195 std::lock_guard< std::mutex> lock(mainThreadFunctionQueueMutex());188 std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex); 196 189 197 190 FunctionWithContextFinder pred(FunctionWithContext(function, context)); -
trunk/Source/WTF/wtf/StackStats.cpp
r162939 r188642 43 43 44 44 // CheckPoint management: 45 std::mutex* StackStats::s_sharedMutex = 0;45 StaticLock StackStats::s_sharedMutex; 46 46 StackStats::CheckPoint* StackStats::s_topCheckPoint = 0; 47 47 StackStats::LayoutCheckPoint* StackStats::s_firstLayoutCheckPoint = 0; … … 58 58 59 59 60 // Initializes locks and the log. Should only be called once.61 void StackStats::initialize()62 {63 s_sharedMutex = std::make_unique<std::mutex>().release();64 dataLogF(" === LOG new stack stats ========\n");65 }66 67 60 StackStats::PerThreadStats::PerThreadStats() 68 61 { … … 77 70 StackStats::CheckPoint::CheckPoint() 78 71 { 79 std::lock_guard< std::mutex> lock(*StackStats::s_sharedMutex);72 std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex); 80 73 WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData()); 81 74 StackStats::PerThreadStats& t = threadData->stackStats(); … … 135 128 StackStats::CheckPoint::~CheckPoint() 136 129 { 137 std::lock_guard< std::mutex> lock(*StackStats::s_sharedMutex);130 std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex); 138 131 WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData()); 139 132 StackStats::PerThreadStats& t = threadData->stackStats(); … … 166 159 void StackStats::probe() 167 160 { 168 std::lock_guard< std::mutex> lock(*StackStats::s_sharedMutex);161 std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex); 169 162 WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData()); 170 163 StackStats::PerThreadStats& t = threadData->stackStats(); … … 227 220 StackStats::probe(); 228 221 229 std::lock_guard< std::mutex> lock(*StackStats::s_sharedMutex);222 std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex); 230 223 WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData()); 231 224 StackStats::PerThreadStats& t = threadData->stackStats(); … … 296 289 StackStats::LayoutCheckPoint::~LayoutCheckPoint() 297 290 { 298 std::lock_guard< std::mutex> lock(*StackStats::s_sharedMutex);291 std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex); 299 292 300 293 // Pop to the previous layout checkpoint: -
trunk/Source/WTF/wtf/StackStats.h
r162939 r188642 29 29 #include "ExportMacros.h" 30 30 #include <mutex> 31 #include <wtf/Lock.h> 31 32 32 33 … … 68 69 }; 69 70 70 static void initialize() { }71 71 static void probe() { } 72 72 }; … … 110 110 }; 111 111 112 // Initializes locks and the log file. Should only be called once.113 static void initialize();114 115 112 // Used for probing the stack at places where we suspect to be high 116 113 // points of stack usage but are NOT check points where stack recursion … … 125 122 private: 126 123 // CheckPoint management: 127 static std::mutex*s_sharedMutex;124 static StaticLock s_sharedMutex; 128 125 static CheckPoint* s_topCheckPoint; 129 126 static LayoutCheckPoint* s_firstLayoutCheckPoint; -
trunk/Source/WTF/wtf/ThreadingPthreads.cpp
r188594 r188642 40 40 #include "HashMap.h" 41 41 #include "RandomNumberSeed.h" 42 #include "StackStats.h"43 42 #include "StdLibExtras.h" 44 43 #include "ThreadFunctionInvocation.h" … … 125 124 initializeRandomNumberGenerator(); 126 125 ThreadIdentifierData::initializeOnce(); 127 StackStats::initialize();128 126 wtfThreadData(); 129 127 initializeDates(); -
trunk/Source/WTF/wtf/mac/DeprecatedSymbolsUsedBySafari.mm
r169518 r188642 31 31 #include "StdLibExtras.h" 32 32 #include <mutex> 33 #include <wtf/Lock.h> 33 34 34 35 // This file contains deprecated symbols that the last released version of Safari uses. … … 46 47 } 47 48 48 static std::mutex& atomicallyInitializedStaticMutex() 49 { 50 static std::once_flag onceFlag; 51 static LazyNeverDestroyed<std::mutex> mutex; 52 std::call_once(onceFlag, []{ 53 mutex.construct(); 54 }); 55 56 return mutex; 57 } 49 static StaticLock atomicallyInitializedStaticMutex; 58 50 59 51 void lockAtomicallyInitializedStaticMutex() 60 52 { 61 atomicallyInitializedStaticMutex ().lock();53 atomicallyInitializedStaticMutex.lock(); 62 54 } 63 55 64 56 void unlockAtomicallyInitializedStaticMutex() 65 57 { 66 atomicallyInitializedStaticMutex ().unlock();58 atomicallyInitializedStaticMutex.unlock(); 67 59 } 68 60 -
trunk/Source/WTF/wtf/text/StringView.cpp
r184867 r188642 30 30 #include <mutex> 31 31 #include <wtf/HashMap.h> 32 #include <wtf/Lock.h> 32 33 #include <wtf/NeverDestroyed.h> 33 34 #include <wtf/unicode/UTF8.h> … … 118 119 } 119 120 120 static std::mutex& underlyingStringsMutex() 121 { 122 static NeverDestroyed<std::mutex> mutex; 123 return mutex; 124 } 121 static StaticLock underlyingStringsMutex; 125 122 126 123 static HashMap<const StringImpl*, StringView::UnderlyingString*>& underlyingStrings() … … 134 131 UnderlyingString* underlyingString; 135 132 { 136 std::lock_guard< std::mutex> lock(underlyingStringsMutex());133 std::lock_guard<StaticLock> lock(underlyingStringsMutex); 137 134 underlyingString = underlyingStrings().take(&stringToBeDestroyed); 138 135 if (!underlyingString) … … 153 150 if (!--m_underlyingString->refCount) { 154 151 if (m_underlyingString->isValid) { 155 std::lock_guard< std::mutex> lock(underlyingStringsMutex());152 std::lock_guard<StaticLock> lock(underlyingStringsMutex); 156 153 underlyingStrings().remove(&m_underlyingString->string); 157 154 } … … 168 165 underlyingString = nullptr; 169 166 else { 170 std::lock_guard< std::mutex> lock(underlyingStringsMutex());167 std::lock_guard<StaticLock> lock(underlyingStringsMutex); 171 168 auto result = underlyingStrings().add(string, nullptr); 172 169 if (result.isNewEntry) -
trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp
r179245 r188642 36 36 #include <mutex> 37 37 #include <unicode/ucol.h> 38 #include <wtf/Lock.h> 38 39 #include <wtf/NeverDestroyed.h> 39 40 #include <wtf/StringExtras.h> … … 51 52 static bool cachedCollatorShouldSortLowercaseFirst; 52 53 53 static std::mutex& cachedCollatorMutex() 54 { 55 static std::once_flag onceFlag; 56 57 static LazyNeverDestroyed<std::mutex> mutex; 58 std::call_once(onceFlag, []{ 59 mutex.construct(); 60 }); 61 62 return mutex; 63 } 54 static StaticLock cachedCollatorMutex; 64 55 65 56 #if !(OS(DARWIN) && USE(CF)) … … 118 109 119 110 { 120 std::lock_guard< std::mutex> lock(cachedCollatorMutex());111 std::lock_guard<StaticLock> lock(cachedCollatorMutex); 121 112 if (cachedCollator && localesMatch(cachedCollatorLocale, locale) && cachedCollatorShouldSortLowercaseFirst == shouldSortLowercaseFirst) { 122 113 m_collator = cachedCollator; … … 148 139 Collator::~Collator() 149 140 { 150 std::lock_guard< std::mutex> lock(cachedCollatorMutex());141 std::lock_guard<StaticLock> lock(cachedCollatorMutex); 151 142 if (cachedCollator) { 152 143 ucol_close(cachedCollator); -
trunk/Source/WebCore/ChangeLog
r188641 r188642 1 2015-08-18 Filip Pizlo <fpizlo@apple.com> 2 3 Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition 4 https://bugs.webkit.org/show_bug.cgi?id=148140 5 6 Reviewed by Geoffrey Garen. 7 8 No new tests because no new behavior. 9 10 * Modules/webaudio/AudioBufferSourceNode.cpp: 11 (WebCore::AudioBufferSourceNode::process): 12 (WebCore::AudioBufferSourceNode::setBuffer): 13 * Modules/webaudio/AudioBufferSourceNode.h: 14 * Modules/webaudio/AudioParamTimeline.cpp: 15 (WebCore::AudioParamTimeline::insertEvent): 16 (WebCore::AudioParamTimeline::cancelScheduledValues): 17 (WebCore::AudioParamTimeline::valueForContextTime): 18 (WebCore::AudioParamTimeline::valuesForTimeRange): 19 * Modules/webaudio/AudioParamTimeline.h: 20 * Modules/webaudio/ConvolverNode.cpp: 21 (WebCore::ConvolverNode::process): 22 (WebCore::ConvolverNode::reset): 23 (WebCore::ConvolverNode::setBuffer): 24 * Modules/webaudio/ConvolverNode.h: 25 * Modules/webaudio/MediaElementAudioSourceNode.cpp: 26 (WebCore::MediaElementAudioSourceNode::process): 27 * Modules/webaudio/MediaElementAudioSourceNode.h: 28 * Modules/webaudio/MediaStreamAudioSourceNode.cpp: 29 (WebCore::MediaStreamAudioSourceNode::setFormat): 30 (WebCore::MediaStreamAudioSourceNode::process): 31 * Modules/webaudio/MediaStreamAudioSourceNode.h: 32 * Modules/webaudio/OscillatorNode.cpp: 33 (WebCore::OscillatorNode::process): 34 (WebCore::OscillatorNode::setPeriodicWave): 35 * Modules/webaudio/OscillatorNode.h: 36 * Modules/webaudio/PannerNode.cpp: 37 (WebCore::PannerNode::process): 38 (WebCore::PannerNode::setPanningModel): 39 * Modules/webaudio/PannerNode.h: 40 * Modules/webaudio/WaveShaperProcessor.cpp: 41 (WebCore::WaveShaperProcessor::setCurve): 42 (WebCore::WaveShaperProcessor::setOversample): 43 (WebCore::WaveShaperProcessor::process): 44 * Modules/webaudio/WaveShaperProcessor.h: 45 * Modules/webdatabase/Database.cpp: 46 (WebCore::retrieveTextResultFromDatabase): 47 (WebCore::guidToVersionMap): 48 (WebCore::Database::Database): 49 (WebCore::Database::performOpenAndVerify): 50 (WebCore::Database::closeDatabase): 51 (WebCore::Database::getCachedVersion): 52 (WebCore::Database::setCachedVersion): 53 (WebCore::guidMutex): Deleted. 54 * Modules/webdatabase/DatabaseManager.cpp: 55 (WebCore::DatabaseManager::existingDatabaseContextFor): 56 (WebCore::DatabaseManager::registerDatabaseContext): 57 (WebCore::DatabaseManager::unregisterDatabaseContext): 58 (WebCore::DatabaseManager::didConstructDatabaseContext): 59 (WebCore::DatabaseManager::didDestructDatabaseContext): 60 (WebCore::DatabaseManager::addProposedDatabase): 61 (WebCore::DatabaseManager::removeProposedDatabase): 62 (WebCore::DatabaseManager::fullPathForDatabase): 63 (WebCore::DatabaseManager::detailsForNameAndOrigin): 64 * Modules/webdatabase/DatabaseManager.h: 65 * bindings/objc/DOMInternal.mm: 66 (getDOMWrapper): 67 (addDOMWrapper): 68 (removeDOMWrapper): 69 (wrapperCacheLock): Deleted. 70 * crypto/CryptoAlgorithmRegistry.cpp: 71 (WebCore::CryptoAlgorithmRegistry::singleton): 72 (WebCore::CryptoAlgorithmRegistry::CryptoAlgorithmRegistry): 73 (WebCore::CryptoAlgorithmRegistry::getIdentifierForName): 74 (WebCore::CryptoAlgorithmRegistry::nameForIdentifier): 75 (WebCore::CryptoAlgorithmRegistry::create): 76 (WebCore::CryptoAlgorithmRegistry::registerAlgorithm): 77 (WebCore::registryMutex): Deleted. 78 * inspector/WorkerDebuggerAgent.cpp: 79 (WebCore::WorkerDebuggerAgent::WorkerDebuggerAgent): 80 (WebCore::WorkerDebuggerAgent::~WorkerDebuggerAgent): 81 (WebCore::WorkerDebuggerAgent::interruptAndDispatchInspectorCommands): 82 * page/WheelEventTestTrigger.cpp: 83 (WebCore::WheelEventTestTrigger::clearAllTestDeferrals): 84 (WebCore::WheelEventTestTrigger::setTestCallbackAndStartNotificationTimer): 85 (WebCore::WheelEventTestTrigger::deferTestsForReason): 86 (WebCore::WheelEventTestTrigger::removeTestDeferralForReason): 87 (WebCore::WheelEventTestTrigger::triggerTestTimerFired): 88 * page/WheelEventTestTrigger.h: 89 * page/scrolling/ScrollingThread.cpp: 90 (WebCore::ScrollingThread::dispatch): 91 (WebCore::ScrollingThread::createThreadIfNeeded): 92 (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): 93 * page/scrolling/ScrollingThread.h: 94 * page/scrolling/mac/ScrollingThreadMac.mm: 95 (WebCore::ScrollingThread::initializeRunLoop): 96 * platform/audio/ReverbConvolver.cpp: 97 (WebCore::ReverbConvolver::~ReverbConvolver): 98 (WebCore::ReverbConvolver::backgroundThreadEntry): 99 (WebCore::ReverbConvolver::process): 100 (WebCore::ReverbConvolver::reset): 101 * platform/audio/ReverbConvolver.h: 102 * platform/ios/wak/WebCoreThreadRun.cpp: 103 * platform/mac/Language.mm: 104 (WebCore::preferredLanguages): 105 (+[WebLanguageChangeObserver languagePreferencesDidChange:]): 106 (WebCore::platformUserPreferredLanguages): 107 (WebCore::preferredLanguagesMutex): Deleted. 108 * platform/network/cf/LoaderRunLoopCF.cpp: 109 (WebCore::emptyPerform): 110 (WebCore::runLoaderThread): 111 (WebCore::loaderRunLoop): 112 (WebCore::loaderRunLoopMutex): Deleted. 113 (WebCore::loaderRunLoopConditionVariable): Deleted. 114 * platform/network/cf/SocketStreamHandleCFNet.cpp: 115 (WebCore::callOnMainThreadAndWait): 116 * platform/network/curl/SocketStreamHandle.h: 117 * platform/network/curl/SocketStreamHandleCurl.cpp: 118 (WebCore::SocketStreamHandle::platformSend): 119 (WebCore::SocketStreamHandle::sendData): 120 * platform/sql/SQLiteDatabaseTracker.cpp: 121 (WebCore::SQLiteDatabaseTracker::setClient): 122 (WebCore::SQLiteDatabaseTracker::incrementTransactionInProgressCount): 123 (WebCore::SQLiteDatabaseTracker::decrementTransactionInProgressCount): 124 (WebCore::SQLiteDatabaseTracker::transactionInProgressMutex): Deleted. 125 * platform/text/TextBreakIterator.cpp: 126 (WebCore::compareAndSwapNonSharedCharacterBreakIterator): 127 * platform/text/TextEncodingRegistry.cpp: 128 (WebCore::newTextCodec): 129 (WebCore::atomicCanonicalTextEncodingName): 130 (WebCore::dumpTextEncodingNameMap): 131 (WebCore::encodingRegistryMutex): Deleted. 132 * workers/WorkerThread.cpp: 133 (WebCore::workerThreads): 134 (WebCore::WorkerThread::workerThreadCount): 135 (WebCore::WorkerThread::WorkerThread): 136 (WebCore::WorkerThread::~WorkerThread): 137 (WebCore::WorkerThread::releaseFastMallocFreeMemoryInAllThreads): 138 (WebCore::threadSetMutex): Deleted. 139 1 140 2015-08-18 Wenson Hsieh <wenson_hsieh@apple.com> 2 141 -
trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp
r185336 r188642 95 95 96 96 // The audio thread can't block on this lock, so we use std::try_to_lock instead. 97 std::unique_lock< std::mutex> lock(m_processMutex, std::try_to_lock);97 std::unique_lock<Lock> lock(m_processMutex, std::try_to_lock); 98 98 if (!lock.owns_lock()) { 99 99 // Too bad - the try_lock() failed. We must be in the middle of changing buffers and were already outputting silence anyway. … … 417 417 418 418 // This synchronizes with process(). 419 std::lock_guard< std::mutex> lock(m_processMutex);419 std::lock_guard<Lock> lock(m_processMutex); 420 420 421 421 if (buffer) { -
trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h
r177733 r188642 33 33 #include "PannerNode.h" 34 34 #include <memory> 35 #include < mutex>35 #include <wtf/Lock.h> 36 36 #include <wtf/PassRefPtr.h> 37 37 #include <wtf/RefPtr.h> … … 160 160 161 161 // This synchronizes process() with setBuffer() which can cause dynamic channel count changes. 162 mutable std::mutexm_processMutex;162 mutable Lock m_processMutex; 163 163 }; 164 164 -
trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp
r185316 r188642 81 81 return; 82 82 83 std::lock_guard< std::mutex> lock(m_eventsMutex);83 std::lock_guard<Lock> lock(m_eventsMutex); 84 84 85 85 unsigned i = 0; … … 103 103 void AudioParamTimeline::cancelScheduledValues(float startTime) 104 104 { 105 std::lock_guard< std::mutex> lock(m_eventsMutex);105 std::lock_guard<Lock> lock(m_eventsMutex); 106 106 107 107 // Remove all events starting at startTime. … … 119 119 120 120 { 121 std::unique_lock< std::mutex> lock(m_eventsMutex, std::try_to_lock);121 std::unique_lock<Lock> lock(m_eventsMutex, std::try_to_lock); 122 122 if (!lock.owns_lock() || !context || !m_events.size() || context->currentTime() < m_events[0].time()) { 123 123 hasValue = false; … … 141 141 { 142 142 // We can't contend the lock in the realtime audio thread. 143 std::unique_lock< std::mutex> lock(m_eventsMutex, std::try_to_lock);143 std::unique_lock<Lock> lock(m_eventsMutex, std::try_to_lock); 144 144 if (!lock.owns_lock()) { 145 145 if (values) { -
trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h
r165676 r188642 31 31 32 32 #include "AudioContext.h" 33 #include <mutex>34 33 #include <runtime/Float32Array.h> 34 #include <wtf/Lock.h> 35 35 #include <wtf/PassRefPtr.h> 36 36 #include <wtf/RefCounted.h> … … 108 108 Vector<ParamEvent> m_events; 109 109 110 std::mutexm_eventsMutex;110 Lock m_eventsMutex; 111 111 }; 112 112 -
trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp
r170774 r188642 74 74 75 75 // Synchronize with possible dynamic changes to the impulse response. 76 std::unique_lock< std::mutex> lock(m_processMutex, std::try_to_lock);76 std::unique_lock<Lock> lock(m_processMutex, std::try_to_lock); 77 77 if (!lock.owns_lock()) { 78 78 // Too bad - the try_lock() failed. We must be in the middle of setting a new impulse response. … … 94 94 void ConvolverNode::reset() 95 95 { 96 std::lock_guard< std::mutex> lock(m_processMutex);96 std::lock_guard<Lock> lock(m_processMutex); 97 97 if (m_reverb) 98 98 m_reverb->reset(); … … 146 146 { 147 147 // Synchronize with process(). 148 std::lock_guard< std::mutex> lock(m_processMutex);148 std::lock_guard<Lock> lock(m_processMutex); 149 149 m_reverb = WTF::move(reverb); 150 150 m_buffer = buffer; -
trunk/Source/WebCore/Modules/webaudio/ConvolverNode.h
r177733 r188642 28 28 #include "AudioNode.h" 29 29 #include <memory> 30 #include < mutex>30 #include <wtf/Lock.h> 31 31 #include <wtf/RefPtr.h> 32 32 … … 68 68 69 69 // This synchronizes dynamic changes to the convolution impulse response with process(). 70 mutable std::mutexm_processMutex;70 mutable Lock m_processMutex; 71 71 72 72 // Normalize the impulse response or not. Must default to true. -
trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp
r185336 r188642 113 113 // If we fail to acquire the lock then the HTMLMediaElement must be in the middle of 114 114 // reconfiguring its playback engine, so we output silence in this case. 115 std::unique_lock< std::mutex> lock(m_processMutex, std::try_to_lock);115 std::unique_lock<Lock> lock(m_processMutex, std::try_to_lock); 116 116 if (!lock.owns_lock()) { 117 117 // We failed to acquire the lock. -
trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h
r184940 r188642 33 33 #include "MultiChannelResampler.h" 34 34 #include <memory> 35 #include < mutex>35 #include <wtf/Lock.h> 36 36 #include <wtf/PassRefPtr.h> 37 37 … … 68 68 69 69 RefPtr<HTMLMediaElement> m_mediaElement; 70 std::mutexm_processMutex;70 Lock m_processMutex; 71 71 72 72 unsigned m_sourceNumberOfChannels; -
trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp
r184940 r188642 73 73 74 74 // Synchronize with process(). 75 std::lock_guard< std::mutex> lock(m_processMutex);75 std::lock_guard<Lock> lock(m_processMutex); 76 76 77 77 m_sourceNumberOfChannels = numberOfChannels; … … 104 104 // If we fail to acquire the lock then the MediaStream must be in the middle of 105 105 // a format change, so we output silence in this case. 106 std::unique_lock< std::mutex> lock(m_processMutex, std::try_to_lock);106 std::unique_lock<Lock> lock(m_processMutex, std::try_to_lock); 107 107 if (!lock.owns_lock()) { 108 108 // We failed to acquire the lock. -
trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h
r184940 r188642 32 32 #include "AudioSourceProviderClient.h" 33 33 #include "MediaStream.h" 34 #include < mutex>34 #include <wtf/Lock.h> 35 35 #include <wtf/PassRefPtr.h> 36 36 … … 69 69 AudioSourceProvider* m_audioSourceProvider; 70 70 71 std::mutexm_processMutex;71 Lock m_processMutex; 72 72 73 73 unsigned m_sourceNumberOfChannels; -
trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp
r185336 r188642 232 232 233 233 // The audio thread can't block on this lock, so we use std::try_to_lock instead. 234 std::unique_lock< std::mutex> lock(m_processMutex, std::try_to_lock);234 std::unique_lock<Lock> lock(m_processMutex, std::try_to_lock); 235 235 if (!lock.owns_lock()) { 236 236 // Too bad - the try_lock() failed. We must be in the middle of changing wave-tables. … … 341 341 342 342 // This synchronizes with process(). 343 std::lock_guard< std::mutex> lock(m_processMutex);343 std::lock_guard<Lock> lock(m_processMutex); 344 344 m_periodicWave = periodicWave; 345 345 m_type = CUSTOM; -
trunk/Source/WebCore/Modules/webaudio/OscillatorNode.h
r184709 r188642 29 29 #include "AudioParam.h" 30 30 #include "AudioScheduledSourceNode.h" 31 #include < mutex>31 #include <wtf/Lock.h> 32 32 #include <wtf/PassRefPtr.h> 33 33 #include <wtf/RefPtr.h> … … 97 97 98 98 // This synchronizes process(). 99 mutable std::mutexm_processMutex;99 mutable Lock m_processMutex; 100 100 101 101 // Stores sample-accurate values calculated according to frequency and detune. -
trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp
r176259 r188642 121 121 122 122 // The audio thread can't block on this lock, so we use std::try_to_lock instead. 123 std::unique_lock< std::mutex> lock(m_pannerMutex, std::try_to_lock);123 std::unique_lock<Lock> lock(m_pannerMutex, std::try_to_lock); 124 124 if (!lock.owns_lock()) { 125 125 // Too bad - The try_lock() failed. We must be in the middle of changing the panner. … … 210 210 if (!m_panner.get() || model != m_panningModel) { 211 211 // This synchronizes with process(). 212 std::lock_guard< std::mutex> lock(m_pannerMutex);212 std::lock_guard<Lock> lock(m_pannerMutex); 213 213 214 214 m_panner = Panner::create(model, sampleRate(), m_hrtfDatabaseLoader.get()); -
trunk/Source/WebCore/Modules/webaudio/PannerNode.h
r184940 r188642 36 36 #include "Panner.h" 37 37 #include <memory> 38 #include < mutex>38 #include <wtf/Lock.h> 39 39 40 40 namespace WebCore { … … 162 162 163 163 // Synchronize process() and setPanningModel() which can change the panner. 164 mutable std::mutexm_pannerMutex;164 mutable Lock m_pannerMutex; 165 165 }; 166 166 -
trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp
r185316 r188642 53 53 { 54 54 // This synchronizes with process(). 55 std::lock_guard< std::mutex> lock(m_processMutex);55 std::lock_guard<Lock> lock(m_processMutex); 56 56 57 57 m_curve = curve; … … 61 61 { 62 62 // This synchronizes with process(). 63 std::lock_guard< std::mutex> lock(m_processMutex);63 std::lock_guard<Lock> lock(m_processMutex); 64 64 65 65 m_oversample = oversample; … … 86 86 87 87 // The audio thread can't block on this lock, so we use std::try_to_lock instead. 88 std::unique_lock< std::mutex> lock(m_processMutex, std::try_to_lock);88 std::unique_lock<Lock> lock(m_processMutex, std::try_to_lock); 89 89 if (!lock.owns_lock()) { 90 90 // Too bad - the try_lock() failed. We must be in the middle of a setCurve() call. -
trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.h
r162368 r188642 30 30 #include "AudioNode.h" 31 31 #include <memory> 32 #include <mutex>33 32 #include <runtime/Float32Array.h> 33 #include <wtf/Lock.h> 34 34 #include <wtf/RefPtr.h> 35 35 … … 67 67 68 68 // This synchronizes process() with setCurve(). 69 mutable std::mutexm_processMutex;69 mutable Lock m_processMutex; 70 70 }; 71 71 -
trunk/Source/WebCore/Modules/webdatabase/Database.cpp
r188594 r188642 158 158 159 159 // FIXME: move all guid-related functions to a DatabaseVersionTracker class. 160 static std::mutex& guidMutex() 161 { 162 static std::once_flag onceFlag; 163 static LazyNeverDestroyed<std::mutex> mutex; 164 165 std::call_once(onceFlag, [] { 166 mutex.construct(); 167 }); 168 169 return mutex; 170 } 160 static StaticLock guidMutex; 171 161 172 162 typedef HashMap<DatabaseGuid, String> GuidVersionMap; … … 234 224 235 225 { 236 std::lock_guard< std::mutex> locker(guidMutex());226 std::lock_guard<StaticLock> locker(guidMutex); 237 227 238 228 m_guid = guidForOriginAndName(securityOrigin()->toString(), name); … … 371 361 String currentVersion; 372 362 { 373 std::lock_guard< std::mutex> locker(guidMutex());363 std::lock_guard<StaticLock> locker(guidMutex); 374 364 375 365 auto entry = guidToVersionMap().find(m_guid); … … 466 456 DatabaseTracker::tracker().removeOpenDatabase(this); 467 457 { 468 std::lock_guard< std::mutex> locker(guidMutex());458 std::lock_guard<StaticLock> locker(guidMutex); 469 459 470 460 auto it = guidToDatabaseMap().find(m_guid); … … 525 515 String Database::getCachedVersion() const 526 516 { 527 std::lock_guard< std::mutex> locker(guidMutex());517 std::lock_guard<StaticLock> locker(guidMutex); 528 518 529 519 return guidToVersionMap().get(m_guid).isolatedCopy(); … … 533 523 { 534 524 // Update the in memory database version map. 535 std::lock_guard< std::mutex> locker(guidMutex());525 std::lock_guard<StaticLock> locker(guidMutex); 536 526 537 527 updateGuidVersionMap(m_guid, actualVersion); -
trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
r188061 r188642 108 108 RefPtr<DatabaseContext> DatabaseManager::existingDatabaseContextFor(ScriptExecutionContext* context) 109 109 { 110 std::lock_guard< std::mutex> lock(m_mutex);110 std::lock_guard<Lock> lock(m_mutex); 111 111 112 112 ASSERT(m_databaseContextRegisteredCount >= 0); … … 139 139 void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext) 140 140 { 141 std::lock_guard< std::mutex> lock(m_mutex);141 std::lock_guard<Lock> lock(m_mutex); 142 142 143 143 ScriptExecutionContext* context = databaseContext->scriptExecutionContext(); … … 150 150 void DatabaseManager::unregisterDatabaseContext(DatabaseContext* databaseContext) 151 151 { 152 std::lock_guard< std::mutex> lock(m_mutex);152 std::lock_guard<Lock> lock(m_mutex); 153 153 154 154 ScriptExecutionContext* context = databaseContext->scriptExecutionContext(); … … 163 163 void DatabaseManager::didConstructDatabaseContext() 164 164 { 165 std::lock_guard< std::mutex> lock(m_mutex);165 std::lock_guard<Lock> lock(m_mutex); 166 166 167 167 m_databaseContextInstanceCount++; … … 170 170 void DatabaseManager::didDestructDatabaseContext() 171 171 { 172 std::lock_guard< std::mutex> lock(m_mutex);172 std::lock_guard<Lock> lock(m_mutex); 173 173 174 174 m_databaseContextInstanceCount--; … … 259 259 void DatabaseManager::addProposedDatabase(ProposedDatabase* proposedDb) 260 260 { 261 std::lock_guard< std::mutex> lock(m_mutex);261 std::lock_guard<Lock> lock(m_mutex); 262 262 263 263 m_proposedDatabases.add(proposedDb); … … 266 266 void DatabaseManager::removeProposedDatabase(ProposedDatabase* proposedDb) 267 267 { 268 std::lock_guard< std::mutex> lock(m_mutex);268 std::lock_guard<Lock> lock(m_mutex); 269 269 270 270 m_proposedDatabases.remove(proposedDb); … … 321 321 { 322 322 { 323 std::lock_guard< std::mutex> lock(m_mutex);323 std::lock_guard<Lock> lock(m_mutex); 324 324 325 325 for (auto* proposedDatabase : m_proposedDatabases) { … … 350 350 { 351 351 { 352 std::lock_guard< std::mutex> lock(m_mutex);352 std::lock_guard<Lock> lock(m_mutex); 353 353 354 354 for (auto* proposedDatabase : m_proposedDatabases) { -
trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.h
r188061 r188642 30 30 #include "DatabaseDetails.h" 31 31 #include "DatabaseError.h" 32 #include <mutex>33 32 #include <wtf/Assertions.h> 34 33 #include <wtf/HashMap.h> 35 34 #include <wtf/HashSet.h> 35 #include <wtf/Lock.h> 36 36 #include <wtf/PassRefPtr.h> 37 37 #include <wtf/Threading.h> … … 150 150 151 151 // This mutex protects m_contextMap, and m_proposedDatabases. 152 std::mutexm_mutex;152 Lock m_mutex; 153 153 }; 154 154 -
trunk/Source/WebCore/bindings/objc/DOMInternal.mm
r176278 r188642 34 34 #import "WebScriptObjectPrivate.h" 35 35 #import "runtime_root.h" 36 #import <wtf/Lock.h> 36 37 #import <wtf/NeverDestroyed.h> 37 38 #import <wtf/spi/cocoa/NSMapTableSPI.h> … … 47 48 48 49 #ifdef NEEDS_WRAPPER_CACHE_LOCK 49 static std::mutex& wrapperCacheLock() 50 { 51 static std::once_flag onceFlag; 52 static LazyNeverDestroyed<std::mutex> mutex; 53 54 std::call_once(onceFlag, [] { 55 mutex.construct(); 56 }); 57 return mutex; 58 } 50 static StaticLock wrapperCacheLock; 59 51 #endif 60 52 … … 79 71 { 80 72 #ifdef NEEDS_WRAPPER_CACHE_LOCK 81 std::lock_guard< std::mutex> lock(wrapperCacheLock());73 std::lock_guard<StaticLock> lock(wrapperCacheLock); 82 74 #endif 83 75 if (!DOMWrapperCache) … … 89 81 { 90 82 #ifdef NEEDS_WRAPPER_CACHE_LOCK 91 std::lock_guard< std::mutex> lock(wrapperCacheLock());83 std::lock_guard<StaticLock> lock(wrapperCacheLock); 92 84 #endif 93 85 if (!DOMWrapperCache) … … 99 91 { 100 92 #ifdef NEEDS_WRAPPER_CACHE_LOCK 101 std::lock_guard< std::mutex> lock(wrapperCacheLock());93 std::lock_guard<StaticLock> lock(wrapperCacheLock); 102 94 #endif 103 95 if (!DOMWrapperCache) -
trunk/Source/WebCore/crypto/CryptoAlgorithmRegistry.cpp
r179409 r188642 30 30 31 31 #include "CryptoAlgorithm.h" 32 #include < mutex>32 #include <wtf/Lock.h> 33 33 #include <wtf/NeverDestroyed.h> 34 34 … … 42 42 } 43 43 44 static std::mutex& registryMutex() 45 { 46 static std::once_flag onceFlag; 47 static LazyNeverDestroyed<std::mutex> mutex; 48 49 std::call_once(onceFlag, []{ 50 mutex.construct(); 51 }); 52 53 return mutex; 54 } 44 static StaticLock registryMutex; 55 45 56 46 CryptoAlgorithmRegistry::CryptoAlgorithmRegistry() … … 64 54 return false; 65 55 66 std::lock_guard< std::mutex> lock(registryMutex());56 std::lock_guard<StaticLock> lock(registryMutex); 67 57 68 58 auto iter = m_nameToIdentifierMap.find(name.isolatedCopy()); … … 76 66 String CryptoAlgorithmRegistry::nameForIdentifier(CryptoAlgorithmIdentifier identifier) 77 67 { 78 std::lock_guard< std::mutex> lock(registryMutex());68 std::lock_guard<StaticLock> lock(registryMutex); 79 69 80 70 return m_identifierToNameMap.get(static_cast<unsigned>(identifier)).isolatedCopy(); … … 83 73 std::unique_ptr<CryptoAlgorithm> CryptoAlgorithmRegistry::create(CryptoAlgorithmIdentifier identifier) 84 74 { 85 std::lock_guard< std::mutex> lock(registryMutex());75 std::lock_guard<StaticLock> lock(registryMutex); 86 76 87 77 auto iter = m_identifierToConstructorMap.find(static_cast<unsigned>(identifier)); … … 94 84 void CryptoAlgorithmRegistry::registerAlgorithm(const String& name, CryptoAlgorithmIdentifier identifier, CryptoAlgorithmConstructor constructor) 95 85 { 96 std::lock_guard< std::mutex> lock(registryMutex());86 std::lock_guard<StaticLock> lock(registryMutex); 97 87 98 88 bool added = m_nameToIdentifierMap.add(name, identifier).isNewEntry; -
trunk/Source/WebCore/inspector/WorkerDebuggerAgent.cpp
r178820 r188642 37 37 #include <inspector/InjectedScriptManager.h> 38 38 #include <inspector/ScriptDebugServer.h> 39 #include < mutex>39 #include <wtf/Lock.h> 40 40 #include <wtf/MessageQueue.h> 41 41 #include <wtf/NeverDestroyed.h> … … 47 47 namespace { 48 48 49 std::mutex& workerDebuggerAgentsMutex() 50 { 51 static std::once_flag onceFlag; 52 static LazyNeverDestroyed<std::mutex> mutex; 53 54 std::call_once(onceFlag, []{ 55 mutex.construct(); 56 }); 57 58 return mutex; 59 } 49 StaticLock workerDebuggerAgentsMutex; 60 50 61 51 typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents; … … 96 86 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) 97 87 { 98 std::lock_guard< std::mutex> lock(workerDebuggerAgentsMutex());88 std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex); 99 89 workerDebuggerAgents().set(&inspectedWorkerGlobalScope->thread(), this); 100 90 } … … 102 92 WorkerDebuggerAgent::~WorkerDebuggerAgent() 103 93 { 104 std::lock_guard< std::mutex> lock(workerDebuggerAgentsMutex());94 std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex); 105 95 106 96 ASSERT(workerDebuggerAgents().contains(&m_inspectedWorkerGlobalScope->thread())); … … 110 100 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* thread) 111 101 { 112 std::lock_guard< std::mutex> lock(workerDebuggerAgentsMutex());102 std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex); 113 103 114 104 if (WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread)) -
trunk/Source/WebCore/page/WheelEventTestTrigger.cpp
r183824 r188642 46 46 void WheelEventTestTrigger::clearAllTestDeferrals() 47 47 { 48 std::lock_guard< std::mutex> lock(m_testTriggerMutex);48 std::lock_guard<Lock> lock(m_testTriggerMutex); 49 49 m_deferTestTriggerReasons.clear(); 50 50 m_testNotificationCallback = std::function<void()>(); … … 56 56 { 57 57 { 58 std::lock_guard< std::mutex> lock(m_testTriggerMutex);58 std::lock_guard<Lock> lock(m_testTriggerMutex); 59 59 m_testNotificationCallback = WTF::move(functionCallback); 60 60 } … … 66 66 void WheelEventTestTrigger::deferTestsForReason(ScrollableAreaIdentifier identifier, DeferTestTriggerReason reason) 67 67 { 68 std::lock_guard< std::mutex> lock(m_testTriggerMutex);68 std::lock_guard<Lock> lock(m_testTriggerMutex); 69 69 auto it = m_deferTestTriggerReasons.find(identifier); 70 70 if (it == m_deferTestTriggerReasons.end()) … … 77 77 void WheelEventTestTrigger::removeTestDeferralForReason(ScrollableAreaIdentifier identifier, DeferTestTriggerReason reason) 78 78 { 79 std::lock_guard< std::mutex> lock(m_testTriggerMutex);79 std::lock_guard<Lock> lock(m_testTriggerMutex); 80 80 auto it = m_deferTestTriggerReasons.find(identifier); 81 81 if (it == m_deferTestTriggerReasons.end()) … … 111 111 112 112 { 113 std::lock_guard< std::mutex> lock(m_testTriggerMutex);113 std::lock_guard<Lock> lock(m_testTriggerMutex); 114 114 if (!m_deferTestTriggerReasons.isEmpty()) { 115 115 #if !LOG_DISABLED -
trunk/Source/WebCore/page/WheelEventTestTrigger.h
r183595 r188642 30 30 #define WheelEventTestTrigger_h 31 31 32 #include <mutex>33 32 #include <set> 34 33 #include <wtf/HashMap.h> 34 #include <wtf/Lock.h> 35 35 #include <wtf/RefPtr.h> 36 36 #include <wtf/RunLoop.h> … … 61 61 std::function<void()> m_testNotificationCallback; 62 62 RunLoop::Timer<WheelEventTestTrigger> m_testTriggerTimer; 63 mutable std::mutexm_testTriggerMutex;63 mutable Lock m_testTriggerMutex; 64 64 WTF::HashMap<ScrollableAreaIdentifier, std::set<DeferTestTriggerReason>> m_deferTestTriggerReasons; 65 65 }; -
trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp
r179409 r188642 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if ENABLE(ASYNC_SCROLLING) 30 30 31 #include <mutex> 31 32 #include <wtf/MainThread.h> 32 33 #include <wtf/NeverDestroyed.h> … … 51 52 52 53 { 53 std::lock_guard< std::mutex> lock(singleton().m_functionsMutex);54 std::lock_guard<Lock> lock(singleton().m_functionsMutex); 54 55 scrollingThread.m_functions.append(function); 55 56 } … … 79 80 // Wait for the thread to initialize the run loop. 80 81 { 81 std::unique_lock< std::mutex> lock(m_initializeRunLoopMutex);82 std::unique_lock<Lock> lock(m_initializeRunLoopMutex); 82 83 83 84 m_threadIdentifier = createThread(threadCallback, this, "WebCore: Scrolling"); … … 107 108 108 109 { 109 std::lock_guard< std::mutex> lock(m_functionsMutex);110 std::lock_guard<Lock> lock(m_functionsMutex); 110 111 functions = WTF::move(m_functions); 111 112 } -
trunk/Source/WebCore/page/scrolling/ScrollingThread.h
r179409 r188642 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if ENABLE(ASYNC_SCROLLING) 30 30 31 #include <condition_variable>32 31 #include <functional> 32 #include <wtf/Condition.h> 33 33 #include <wtf/Forward.h> 34 #include <wtf/Lock.h> 34 35 #include <wtf/Noncopyable.h> 35 36 #include <wtf/Threading.h> … … 75 76 ThreadIdentifier m_threadIdentifier; 76 77 77 std::condition_variablem_initializeRunLoopConditionVariable;78 std::mutexm_initializeRunLoopMutex;78 Condition m_initializeRunLoopConditionVariable; 79 Lock m_initializeRunLoopMutex; 79 80 80 std::mutexm_functionsMutex;81 Lock m_functionsMutex; 81 82 Vector<std::function<void ()>> m_functions; 82 83 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingThreadMac.mm
r169955 r188642 29 29 #if ENABLE(ASYNC_SCROLLING) 30 30 31 #include <mutex> 32 31 33 namespace WebCore { 32 34 … … 35 37 // Initialize the run loop. 36 38 { 37 std::lock_guard< std::mutex> lock(m_initializeRunLoopMutex);39 std::lock_guard<Lock> lock(m_initializeRunLoopMutex); 38 40 39 41 m_threadRunLoop = CFRunLoopGetCurrent(); … … 43 45 CFRunLoopAddSource(CFRunLoopGetCurrent(), m_threadRunLoopSource.get(), kCFRunLoopDefaultMode); 44 46 45 m_initializeRunLoopConditionVariable.notify _all();47 m_initializeRunLoopConditionVariable.notifyAll(); 46 48 } 47 49 -
trunk/Source/WebCore/platform/audio/ReverbConvolver.cpp
r170774 r188642 35 35 #include "VectorMath.h" 36 36 #include "AudioBus.h" 37 #include <mutex> 37 38 38 39 namespace WebCore { … … 141 142 // Wake up thread so it can return 142 143 { 143 std::lock_guard< std::mutex> lock(m_backgroundThreadMutex);144 std::lock_guard<Lock> lock(m_backgroundThreadMutex); 144 145 m_moreInputBuffered = true; 145 m_backgroundThreadConditionVariable.notify _one();146 m_backgroundThreadConditionVariable.notifyOne(); 146 147 } 147 148 … … 156 157 m_moreInputBuffered = false; 157 158 { 158 std::unique_lock< std::mutex> lock(m_backgroundThreadMutex);159 std::unique_lock<Lock> lock(m_backgroundThreadMutex); 159 160 160 161 m_backgroundThreadConditionVariable.wait(lock, [this] { return m_moreInputBuffered || m_wantsToExit; }); … … 210 211 // and frequently (around every 3ms). The background thread is processing well into the future and has a considerable amount of 211 212 // leeway here... 212 std::unique_lock< std::mutex> lock(m_backgroundThreadMutex, std::try_to_lock);213 std::unique_lock<Lock> lock(m_backgroundThreadMutex, std::try_to_lock); 213 214 if (!lock.owns_lock()) 214 215 return; 215 216 216 217 m_moreInputBuffered = true; 217 m_backgroundThreadConditionVariable.notify _one();218 m_backgroundThreadConditionVariable.notifyOne(); 218 219 } 219 220 -
trunk/Source/WebCore/platform/audio/ReverbConvolver.h
r165676 r188642 1 1 /* 2 2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2015 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 36 37 #include "ReverbConvolverStage.h" 37 38 #include "ReverbInputBuffer.h" 38 #include <condition_variable>39 39 #include <memory> 40 #include <mutex> 40 #include <wtf/Condition.h> 41 #include <wtf/Lock.h> 41 42 #include <wtf/RefCounted.h> 42 43 #include <wtf/Threading.h> … … 89 90 bool m_wantsToExit; 90 91 bool m_moreInputBuffered; 91 mutable std::mutexm_backgroundThreadMutex;92 mutable std::condition_variablem_backgroundThreadConditionVariable;92 mutable Lock m_backgroundThreadMutex; 93 mutable Condition m_backgroundThreadConditionVariable; 93 94 }; 94 95 -
trunk/Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp
r162292 r188642 1 1 /* 2 * Copyright (C) 2010 Apple Inc. All rights reserved.2 * Copyright (C) 2010, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include "WebCoreThread.h" 32 32 #include "WebCoreThreadInternal.h" 33 #include <condition_variable> 33 #include <mutex> 34 #include <wtf/Condition.h> 35 #include <wtf/Lock.h> 34 36 #include <wtf/Vector.h> 35 37 … … 45 47 void waitForCompletion() 46 48 { 47 std::unique_lock< std::mutex> lock(m_stateMutex);49 std::unique_lock<Lock> lock(m_stateMutex); 48 50 49 51 m_completionConditionVariable.wait(lock, [this] { return m_completed; }); … … 52 54 void setCompleted() 53 55 { 54 std::lock_guard< std::mutex> lock(m_stateMutex);56 std::lock_guard<Lock> lock(m_stateMutex); 55 57 56 58 ASSERT(!m_completed); 57 59 m_completed = true; 58 m_completionConditionVariable.notify _one();60 m_completionConditionVariable.notifyOne(); 59 61 } 60 62 61 63 private: 62 std::mutexm_stateMutex;63 std::condition_variablem_completionConditionVariable;64 Lock m_stateMutex; 65 Condition m_completionConditionVariable; 64 66 bool m_completed; 65 67 }; … … 111 113 typedef WTF::Vector<WebThreadBlock> WebThreadRunQueue; 112 114 113 static std::mutex*runQueueMutex;115 static StaticLock runQueueMutex; 114 116 static CFRunLoopSourceRef runSource; 115 117 static WebThreadRunQueue* runQueue; … … 119 121 UNUSED_PARAM(info); 120 122 ASSERT(WebThreadIsCurrent()); 121 ASSERT(runQueueMutex);122 123 ASSERT(runSource); 123 124 ASSERT(runQueue); … … 125 126 WebThreadRunQueue queueCopy; 126 127 { 127 std::lock_guard< std::mutex> lock(*runQueueMutex);128 std::lock_guard<StaticLock> lock(runQueueMutex); 128 129 queueCopy = *runQueue; 129 130 runQueue->clear(); … … 141 142 } 142 143 143 ASSERT(runQueueMutex);144 144 ASSERT(runSource); 145 145 ASSERT(runQueue); … … 150 150 151 151 { 152 std::lock_guard< std::mutex> lock(*runQueueMutex);152 std::lock_guard<StaticLock> lock(runQueueMutex); 153 153 runQueue->append(WebThreadBlock(task, state)); 154 154 } … … 176 176 { 177 177 ASSERT(!runQueue); 178 ASSERT(!runQueueMutex);179 178 ASSERT(!runSource); 180 179 … … 186 185 runSource = CFRunLoopSourceCreate(NULL, -1, &runSourceContext); 187 186 CFRunLoopAddSource(WebThreadRunLoop(), runSource, kCFRunLoopDefaultMode); 188 189 runQueueMutex = std::make_unique<std::mutex>().release();190 187 }); 191 188 } -
trunk/Source/WebCore/platform/mac/Language.mm
r185816 r188642 32 32 #import <mutex> 33 33 #import <wtf/Assertions.h> 34 #import <wtf/Lock.h> 34 35 #import <wtf/NeverDestroyed.h> 35 36 #import <wtf/RetainPtr.h> … … 38 39 namespace WebCore { 39 40 40 static std::mutex& preferredLanguagesMutex() 41 { 42 static dispatch_once_t onceToken; 43 static std::mutex* mutex; 44 45 dispatch_once(&onceToken, ^{ 46 mutex = std::make_unique<std::mutex>().release(); 47 }); 48 49 return *mutex; 50 } 41 static StaticLock preferredLanguagesMutex; 51 42 52 43 static Vector<String>& preferredLanguages() … … 68 59 69 60 { 70 std::lock_guard< std::mutex> lock(WebCore::preferredLanguagesMutex());61 std::lock_guard<StaticLock> lock(WebCore::preferredLanguagesMutex); 71 62 WebCore::preferredLanguages().clear(); 72 63 } … … 119 110 BEGIN_BLOCK_OBJC_EXCEPTIONS; 120 111 121 std::lock_guard< std::mutex> lock(preferredLanguagesMutex());112 std::lock_guard<StaticLock> lock(preferredLanguagesMutex); 122 113 Vector<String>& userPreferredLanguages = preferredLanguages(); 123 114 -
trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp
r162292 r188642 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 31 31 #include <CoreFoundation/CoreFoundation.h> 32 #include <condition_variable>33 32 #include <limits> 33 #include <mutex> 34 34 #include <wtf/AutodrainedPool.h> 35 #include <wtf/Condition.h> 36 #include <wtf/Lock.h> 35 37 #include <wtf/MainThread.h> 36 38 #include <wtf/NeverDestroyed.h> … … 41 43 static CFRunLoopRef loaderRunLoopObject = 0; 42 44 43 static std::mutex& loaderRunLoopMutex() 44 { 45 static NeverDestroyed<std::mutex> mutex; 46 47 return mutex; 48 } 49 50 static std::condition_variable& loaderRunLoopConditionVariable() 51 { 52 static NeverDestroyed<std::condition_variable> conditionVariable; 53 54 return conditionVariable; 55 } 45 static StaticLock loaderRunLoopMutex; 46 static StaticCondition loaderRunLoopConditionVariable; 56 47 57 48 static void emptyPerform(void*) … … 62 53 { 63 54 { 64 std::lock_guard< std::mutex> lock(loaderRunLoopMutex());55 std::lock_guard<StaticLock> lock(loaderRunLoopMutex); 65 56 66 57 loaderRunLoopObject = CFRunLoopGetCurrent(); … … 71 62 CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode); 72 63 73 loaderRunLoopConditionVariable ().notify_one();64 loaderRunLoopConditionVariable.notifyOne(); 74 65 } 75 66 … … 85 76 ASSERT(isMainThread()); 86 77 87 std::unique_lock< std::mutex> lock(loaderRunLoopMutex());78 std::unique_lock<StaticLock> lock(loaderRunLoopMutex); 88 79 89 80 if (!loaderRunLoopObject) { 90 81 createThread(runLoaderThread, 0, "WebCore: CFNetwork Loader"); 91 82 92 loaderRunLoopConditionVariable ().wait(lock, [] { return loaderRunLoopObject; });83 loaderRunLoopConditionVariable.wait(lock, [] { return loaderRunLoopObject; }); 93 84 } 94 85 -
trunk/Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp
r186476 r188642 40 40 #include "SocketStreamError.h" 41 41 #include "SocketStreamHandleClient.h" 42 #include < condition_variable>43 #include < mutex>42 #include <wtf/Condition.h> 43 #include <wtf/Lock.h> 44 44 #include <wtf/MainThread.h> 45 45 #include <wtf/text/WTFString.h> … … 137 137 } 138 138 139 std::mutexmutex;140 std::condition_variableconditionVariable;139 Lock mutex; 140 Condition conditionVariable; 141 141 142 142 bool isFinished = false; … … 145 145 function(); 146 146 147 std::lock_guard< std::mutex> lock(mutex);147 std::lock_guard<Lock> lock(mutex); 148 148 isFinished = true; 149 conditionVariable.notify _one();149 conditionVariable.notifyOne(); 150 150 }); 151 151 152 std::unique_lock< std::mutex> lock(mutex);152 std::unique_lock<Lock> lock(mutex); 153 153 conditionVariable.wait(lock, [&] { return isFinished; }); 154 154 } -
trunk/Source/WebCore/platform/network/curl/SocketStreamHandle.h
r186479 r188642 41 41 #include <curl/curl.h> 42 42 43 #include <mutex>44 45 43 #include <wtf/Deque.h> 44 #include <wtf/Lock.h> 46 45 #include <wtf/RefCounted.h> 47 46 #include <wtf/Threading.h> … … 106 105 ThreadIdentifier m_workerThread { 0 }; 107 106 std::atomic<bool> m_stopThread { false }; 108 std::mutexm_mutexSend;109 std::mutexm_mutexReceive;107 Lock m_mutexSend; 108 Lock m_mutexReceive; 110 109 Deque<SocketData> m_sendData; 111 110 Deque<SocketData> m_receiveData; -
trunk/Source/WebCore/platform/network/curl/SocketStreamHandleCurl.cpp
r184389 r188642 68 68 auto copy = createCopy(data, length); 69 69 70 std::lock_guard< std::mutex> lock(m_mutexSend);70 std::lock_guard<Lock> lock(m_mutexSend); 71 71 m_sendData.append(SocketData { WTF::move(copy), length }); 72 72 … … 147 147 auto copy = createCopy(sendData.data.get() + totalBytesSent, restLength); 148 148 149 std::lock_guard< std::mutex> lock(m_mutexSend);149 std::lock_guard<Lock> lock(m_mutexSend); 150 150 m_sendData.prepend(SocketData { WTF::move(copy), restLength }); 151 151 -
trunk/Source/WebCore/platform/sql/SQLiteDatabaseTracker.cpp
r162787 r188642 28 28 29 29 #include <mutex> 30 #include <wtf/ NeverDestroyed.h>30 #include <wtf/Lock.h> 31 31 32 32 namespace WebCore { … … 37 37 static unsigned s_transactionInProgressCounter = 0; 38 38 39 static std::mutex& transactionInProgressMutex() 40 { 41 static NeverDestroyed<std::mutex> tipMutex; 42 return tipMutex; 43 } 39 static StaticLock transactionInProgressMutex; 44 40 45 41 void setClient(SQLiteDatabaseTrackerClient* client) … … 55 51 return; 56 52 57 std::lock_guard< std::mutex> lock(transactionInProgressMutex());53 std::lock_guard<StaticLock> lock(transactionInProgressMutex); 58 54 59 55 s_transactionInProgressCounter++; … … 67 63 return; 68 64 69 std::lock_guard< std::mutex> lock(transactionInProgressMutex());65 std::lock_guard<StaticLock> lock(transactionInProgressMutex); 70 66 71 67 ASSERT(s_transactionInProgressCounter); -
trunk/Source/WebCore/platform/text/TextBreakIterator.cpp
r181351 r188642 28 28 #include <mutex> 29 29 #include <wtf/Atomics.h> 30 #include <wtf/Lock.h> 30 31 #include <wtf/text/StringView.h> 31 32 … … 766 767 return WTF::weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), expected, newValue); 767 768 #else 768 DEPRECATED_DEFINE_STATIC_LOCAL(std::mutex, nonSharedCharacterBreakIteratorMutex, ());769 std::lock_guard< std::mutex> locker(nonSharedCharacterBreakIteratorMutex);769 static StaticLock nonSharedCharacterBreakIteratorMutex; 770 std::lock_guard<StaticLock> locker(nonSharedCharacterBreakIteratorMutex); 770 771 if (nonSharedCharacterBreakIterator != expected) 771 772 return false; -
trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp
r174757 r188642 38 38 #include <wtf/HashMap.h> 39 39 #include <wtf/HashSet.h> 40 #include <wtf/Lock.h> 40 41 #include <wtf/MainThread.h> 41 42 #include <wtf/NeverDestroyed.h> … … 107 108 typedef HashMap<const char*, TextCodecFactory> TextCodecMap; 108 109 109 static std::mutex& encodingRegistryMutex() 110 { 111 // We don't have to construct this mutex in a thread safe way because this function 112 // is called on the main thread for any page before it is used in worker threads. 113 static NeverDestroyed<std::mutex> mutex; 114 115 return mutex; 116 } 110 static StaticLock encodingRegistryMutex; 117 111 118 112 static TextEncodingNameMap* textEncodingNameMap; … … 295 289 std::unique_ptr<TextCodec> newTextCodec(const TextEncoding& encoding) 296 290 { 297 std::lock_guard< std::mutex> lock(encodingRegistryMutex());291 std::lock_guard<StaticLock> lock(encodingRegistryMutex); 298 292 299 293 ASSERT(textCodecMap); … … 311 305 buildBaseTextCodecMaps(); 312 306 313 std::lock_guard< std::mutex> lock(encodingRegistryMutex());307 std::lock_guard<StaticLock> lock(encodingRegistryMutex); 314 308 315 309 if (const char* atomicName = textEncodingNameMap->get(name)) … … 378 372 fprintf(stderr, "Dumping %u entries in WebCore::textEncodingNameMap...\n", size); 379 373 380 std::lock_guard< std::mutex> lock(encodingRegistryMutex());374 std::lock_guard<StaticLock> lock(encodingRegistryMutex); 381 375 382 376 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); -
trunk/Source/WebCore/workers/WorkerThread.cpp
r188594 r188642 36 36 #include "URL.h" 37 37 #include <utility> 38 #include <wtf/Lock.h> 38 39 #include <wtf/NeverDestroyed.h> 39 40 #include <wtf/Noncopyable.h> … … 47 48 namespace WebCore { 48 49 49 static std::mutex& threadSetMutex() 50 { 51 static std::once_flag onceFlag; 52 static LazyNeverDestroyed<std::mutex> mutex; 53 54 std::call_once(onceFlag, []{ 55 mutex.construct(); 56 }); 57 58 return mutex; 59 } 50 static StaticLock threadSetMutex; 60 51 61 52 static HashSet<WorkerThread*>& workerThreads() … … 68 59 unsigned WorkerThread::workerThreadCount() 69 60 { 70 std::lock_guard< std::mutex> lock(threadSetMutex());61 std::lock_guard<StaticLock> lock(threadSetMutex); 71 62 72 63 return workerThreads().size(); … … 107 98 #endif 108 99 { 109 std::lock_guard< std::mutex> lock(threadSetMutex());100 std::lock_guard<StaticLock> lock(threadSetMutex); 110 101 111 102 workerThreads().add(this); … … 114 105 WorkerThread::~WorkerThread() 115 106 { 116 std::lock_guard< std::mutex> lock(threadSetMutex());107 std::lock_guard<StaticLock> lock(threadSetMutex); 117 108 118 109 ASSERT(workerThreads().contains(this)); … … 222 213 void WorkerThread::releaseFastMallocFreeMemoryInAllThreads() 223 214 { 224 std::lock_guard< std::mutex> lock(threadSetMutex());215 std::lock_guard<StaticLock> lock(threadSetMutex); 225 216 226 217 for (auto* workerThread : workerThreads()) { -
trunk/Source/WebKit2/ChangeLog
r188640 r188642 1 2015-08-18 Filip Pizlo <fpizlo@apple.com> 2 3 Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition 4 https://bugs.webkit.org/show_bug.cgi?id=148140 5 6 Reviewed by Geoffrey Garen. 7 8 * NetworkProcess/cache/NetworkCacheStorage.cpp: 9 (WebKit::NetworkCache::Storage::traverse): 10 * Platform/IPC/Connection.cpp: 11 (IPC::Connection::SyncMessageState::processIncomingMessage): 12 (IPC::Connection::SyncMessageState::dispatchMessages): 13 (IPC::Connection::SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesForConnection): 14 (IPC::Connection::sendMessage): 15 (IPC::Connection::waitForMessage): 16 (IPC::Connection::processIncomingMessage): 17 (IPC::Connection::installIncomingSyncMessageCallback): 18 (IPC::Connection::uninstallIncomingSyncMessageCallback): 19 (IPC::Connection::hasIncomingSyncMessage): 20 (IPC::Connection::connectionDidClose): 21 (IPC::Connection::sendOutgoingMessages): 22 (IPC::Connection::enqueueIncomingMessage): 23 (IPC::Connection::dispatchOneMessage): 24 * Platform/IPC/Connection.h: 25 * Shared/BlockingResponseMap.h: 26 (BlockingResponseMap::waitForResponse): 27 (BlockingResponseMap::didReceiveResponse): 28 (BlockingResponseMap::cancel): 29 * UIProcess/Plugins/gtk/PluginInfoCache.cpp: 30 (WebKit::PluginInfoCache::saveToFile): 31 (WebKit::PluginInfoCache::updatePluginInfo): 32 * UIProcess/Plugins/gtk/PluginInfoCache.h: 33 * UIProcess/mac/WKPrintingView.h: 34 * UIProcess/mac/WKPrintingView.mm: 35 (-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]): 36 (prepareDataForPrintingOnSecondaryThread): 37 (-[WKPrintingView knowsPageRange:]): 38 1 39 2015-08-19 Chris Dumez <cdumez@apple.com> 2 40 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp
r188640 r188642 33 33 #include "NetworkCacheFileSystem.h" 34 34 #include "NetworkCacheIOChannel.h" 35 #include <condition_variable> 35 #include <mutex> 36 #include <wtf/Condition.h> 37 #include <wtf/Lock.h> 36 38 #include <wtf/RandomNumber.h> 37 39 #include <wtf/RunLoop.h> … … 120 122 const TraverseHandler handler; 121 123 122 std::mutexactiveMutex;123 std::condition_variableactiveCondition;124 Lock activeMutex; 125 Condition activeCondition; 124 126 unsigned activeCount { 0 }; 125 127 }; … … 792 794 bodyShareCount = m_blobStorage.shareCount(bodyPathForRecordPath(recordPath)); 793 795 794 std::unique_lock< std::mutex> lock(traverseOperation.activeMutex);796 std::unique_lock<Lock> lock(traverseOperation.activeMutex); 795 797 ++traverseOperation.activeCount; 796 798 … … 815 817 } 816 818 817 std::lock_guard< std::mutex> lock(traverseOperation.activeMutex);819 std::lock_guard<Lock> lock(traverseOperation.activeMutex); 818 820 --traverseOperation.activeCount; 819 traverseOperation.activeCondition.notify _one();821 traverseOperation.activeCondition.notifyOne(); 820 822 }); 821 823 … … 826 828 }); 827 829 // Wait for all reads to finish. 828 std::unique_lock< std::mutex> lock(traverseOperation.activeMutex);830 std::unique_lock<Lock> lock(traverseOperation.activeMutex); 829 831 traverseOperation.activeCondition.wait(lock, [&traverseOperation] { 830 832 return !traverseOperation.activeCount; -
trunk/Source/WebKit2/Platform/IPC/Connection.cpp
r188594 r188642 87 87 88 88 // Protects m_didScheduleDispatchMessagesWorkSet and m_messagesToDispatchWhileWaitingForSyncReply. 89 std::mutexm_mutex;89 Lock m_mutex; 90 90 91 91 // The set of connections for which we've scheduled a call to dispatchMessageAndResetDidScheduleDispatchMessagesForConnection. … … 132 132 133 133 { 134 std::lock_guard< std::mutex> lock(m_mutex);134 std::lock_guard<Lock> lock(m_mutex); 135 135 136 136 if (m_didScheduleDispatchMessagesWorkSet.add(&connection).isNewEntry) { … … 156 156 157 157 { 158 std::lock_guard< std::mutex> lock(m_mutex);158 std::lock_guard<Lock> lock(m_mutex); 159 159 m_messagesToDispatchWhileWaitingForSyncReply.swap(messagesToDispatchWhileWaitingForSyncReply); 160 160 } … … 176 176 177 177 if (!messagesToPutBack.isEmpty()) { 178 std::lock_guard< std::mutex> lock(m_mutex);178 std::lock_guard<Lock> lock(m_mutex); 179 179 180 180 for (auto& message : messagesToPutBack) … … 186 186 { 187 187 { 188 std::lock_guard< std::mutex> lock(m_mutex);188 std::lock_guard<Lock> lock(m_mutex); 189 189 ASSERT(m_didScheduleDispatchMessagesWorkSet.contains(&connection)); 190 190 m_didScheduleDispatchMessagesWorkSet.remove(&connection); … … 364 364 365 365 { 366 std::lock_guard< std::mutex> lock(m_outgoingMessagesMutex);366 std::lock_guard<Lock> lock(m_outgoingMessagesMutex); 367 367 m_outgoingMessages.append(WTF::move(encoder)); 368 368 } … … 389 389 // First, check if this message is already in the incoming messages queue. 390 390 { 391 std::lock_guard< std::mutex> lock(m_incomingMessagesMutex);391 std::lock_guard<Lock> lock(m_incomingMessagesMutex); 392 392 393 393 for (auto it = m_incomingMessages.begin(), end = m_incomingMessages.end(); it != end; ++it) { … … 415 415 416 416 { 417 std::lock_guard< std::mutex> lock(m_waitForMessageMutex);417 std::lock_guard<Lock> lock(m_waitForMessageMutex); 418 418 419 419 // We don't support having multiple clients waiting for messages. … … 424 424 425 425 // Now wait for it to be set. 426 Condition::Clock::time_point absoluteTimeout = Condition::Clock::now() + timeout; 426 427 while (true) { 427 std::unique_lock< std::mutex> lock(m_waitForMessageMutex);428 std::unique_lock<Lock> lock(m_waitForMessageMutex); 428 429 429 430 if (m_waitingForMessage->decoder) { … … 434 435 435 436 // Now we wait. 436 std::cv_status status = m_waitForMessageCondition.wait_for(lock, timeout);437 bool didTimeout = !m_waitForMessageCondition.waitUntil(lock, absoluteTimeout); 437 438 // We timed out, lost our connection, or a sync message came in with InterruptWaitingIfSyncMessageArrives, so stop waiting. 438 if ( status == std::cv_status::timeout || m_waitingForMessage->messageWaitingInterrupted)439 if (didTimeout || m_waitingForMessage->messageWaitingInterrupted) 439 440 break; 440 441 } … … 671 672 672 673 if (message->isSyncMessage()) { 673 std::lock_guard< std::mutex> lock(m_incomingSyncMessageCallbackMutex);674 std::lock_guard<Lock> lock(m_incomingSyncMessageCallbackMutex); 674 675 675 676 for (auto& callback : m_incomingSyncMessageCallbacks.values()) … … 687 688 // Check if we're waiting for this message. 688 689 { 689 std::lock_guard< std::mutex> lock(m_waitForMessageMutex);690 std::lock_guard<Lock> lock(m_waitForMessageMutex); 690 691 691 692 if (m_waitingForMessage && m_waitingForMessage->messageReceiverName == message->messageReceiverName() && m_waitingForMessage->messageName == message->messageName() && m_waitingForMessage->destinationID == message->destinationID()) { 692 693 m_waitingForMessage->decoder = WTF::move(message); 693 694 ASSERT(m_waitingForMessage->decoder); 694 m_waitForMessageCondition.notify _one();695 m_waitForMessageCondition.notifyOne(); 695 696 return; 696 697 } … … 698 699 if (m_waitingForMessage && (m_waitingForMessage->waitForMessageFlags & InterruptWaitingIfSyncMessageArrives) && message->isSyncMessage()) { 699 700 m_waitingForMessage->messageWaitingInterrupted = true; 700 m_waitForMessageCondition.notify _one();701 m_waitForMessageCondition.notifyOne(); 701 702 } 702 703 } … … 707 708 uint64_t Connection::installIncomingSyncMessageCallback(std::function<void ()> callback) 708 709 { 709 std::lock_guard< std::mutex> lock(m_incomingSyncMessageCallbackMutex);710 std::lock_guard<Lock> lock(m_incomingSyncMessageCallbackMutex); 710 711 711 712 m_nextIncomingSyncMessageCallbackID++; … … 721 722 void Connection::uninstallIncomingSyncMessageCallback(uint64_t callbackID) 722 723 { 723 std::lock_guard< std::mutex> lock(m_incomingSyncMessageCallbackMutex);724 std::lock_guard<Lock> lock(m_incomingSyncMessageCallbackMutex); 724 725 m_incomingSyncMessageCallbacks.remove(callbackID); 725 726 } … … 727 728 bool Connection::hasIncomingSyncMessage() 728 729 { 729 std::lock_guard< std::mutex> lock(m_incomingMessagesMutex);730 std::lock_guard<Lock> lock(m_incomingMessagesMutex); 730 731 731 732 for (auto& message : m_incomingMessages) { … … 764 765 765 766 { 766 std::lock_guard< std::mutex> lock(m_waitForMessageMutex);767 std::lock_guard<Lock> lock(m_waitForMessageMutex); 767 768 if (m_waitingForMessage) 768 769 m_waitingForMessage->messageWaitingInterrupted = true; 769 770 } 770 m_waitForMessageCondition.notify _all();771 m_waitForMessageCondition.notifyAll(); 771 772 772 773 if (m_didCloseOnConnectionWorkQueueCallback) … … 804 805 805 806 { 806 std::lock_guard< std::mutex> lock(m_outgoingMessagesMutex);807 std::lock_guard<Lock> lock(m_outgoingMessagesMutex); 807 808 if (m_outgoingMessages.isEmpty()) 808 809 break; … … 863 864 { 864 865 { 865 std::lock_guard< std::mutex> lock(m_incomingMessagesMutex);866 std::lock_guard<Lock> lock(m_incomingMessagesMutex); 866 867 m_incomingMessages.append(WTF::move(incomingMessage)); 867 868 } … … 919 920 920 921 { 921 std::lock_guard< std::mutex> lock(m_incomingMessagesMutex);922 std::lock_guard<Lock> lock(m_incomingMessagesMutex); 922 923 if (m_incomingMessages.isEmpty()) 923 924 return; -
trunk/Source/WebKit2/Platform/IPC/Connection.h
r188594 r188642 35 35 #include "ProcessType.h" 36 36 #include <atomic> 37 #include < condition_variable>37 #include <wtf/Condition.h> 38 38 #include <wtf/Deque.h> 39 39 #include <wtf/Forward.h> … … 260 260 261 261 // Incoming messages. 262 std::mutexm_incomingMessagesMutex;262 Lock m_incomingMessagesMutex; 263 263 Deque<std::unique_ptr<MessageDecoder>> m_incomingMessages; 264 264 265 265 // Outgoing messages. 266 std::mutexm_outgoingMessagesMutex;266 Lock m_outgoingMessagesMutex; 267 267 Deque<std::unique_ptr<MessageEncoder>> m_outgoingMessages; 268 268 269 std::condition_variablem_waitForMessageCondition;270 std::mutexm_waitForMessageMutex;269 Condition m_waitForMessageCondition; 270 Lock m_waitForMessageMutex; 271 271 272 272 WaitForMessageState* m_waitingForMessage; … … 308 308 SecondaryThreadPendingSyncReplyMap m_secondaryThreadPendingSyncReplyMap; 309 309 310 std::mutexm_incomingSyncMessageCallbackMutex;310 Lock m_incomingSyncMessageCallbackMutex; 311 311 HashMap<uint64_t, std::function<void ()>> m_incomingSyncMessageCallbacks; 312 312 RefPtr<WorkQueue> m_incomingSyncMessageCallbackQueue; -
trunk/Source/WebKit2/Shared/BlockingResponseMap.h
r170774 r188642 27 27 #define BlockingResponseMap_h 28 28 29 #include < condition_variable>29 #include <wtf/Condition.h> 30 30 #include <wtf/HashMap.h> 31 #include <wtf/Lock.h> 31 32 #include <wtf/Noncopyable.h> 32 33 … … 41 42 { 42 43 while (true) { 43 std::unique_lock< std::mutex> lock(m_mutex);44 std::unique_lock<Lock> lock(m_mutex); 44 45 45 46 if (m_canceled) … … 57 58 void didReceiveResponse(uint64_t requestID, std::unique_ptr<T> response) 58 59 { 59 std::lock_guard< std::mutex> lock(m_mutex);60 std::lock_guard<Lock> lock(m_mutex); 60 61 ASSERT(!m_responses.contains(requestID)); 61 62 62 63 m_responses.set(requestID, WTF::move(response)); 63 64 64 // FIXME: Waking up all threads is quite inefficient.65 m_condition.notify _all();65 // FIXME: Could get a slight speed-up from using notifyOne(). 66 m_condition.notifyAll(); 66 67 } 67 68 … … 70 71 m_canceled = true; 71 72 72 // FIXME: Waking up all threads is quite inefficient.73 m_condition.notify _all();73 // FIXME: Could get a slight speed-up from using notifyOne(). 74 m_condition.notifyAll(); 74 75 } 75 76 76 77 private: 77 std::mutexm_mutex;78 std::condition_variablem_condition;78 Lock m_mutex; 79 Condition m_condition; 79 80 80 81 HashMap<uint64_t, std::unique_ptr<T>> m_responses; -
trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp
r179409 r188642 80 80 void PluginInfoCache::saveToFile() 81 81 { 82 std::lock_guard< std::mutex> lock(m_mutex);82 std::lock_guard<Lock> lock(m_mutex); 83 83 84 84 gsize dataLength; … … 143 143 // Save the cache file in an idle to make sure it happens in the main thread and 144 144 // it's done only once when this is called multiple times in a very short time. 145 std::lock_guard< std::mutex> lock(m_mutex);145 std::lock_guard<Lock> lock(m_mutex); 146 146 if (m_saveToFileIdle.isScheduled()) 147 147 return; -
trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h
r185502 r188642 31 31 #include "PluginModuleInfo.h" 32 32 #include <mutex> 33 #include <wtf/Lock.h> 33 34 #include <wtf/NeverDestroyed.h> 34 35 #include <wtf/glib/GMainLoopSource.h> … … 56 57 GMainLoopSource m_saveToFileIdle; 57 58 bool m_readOnlyMode; 58 std::mutexm_mutex;59 Lock m_mutex; 59 60 }; 60 61 -
trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.h
r180441 r188642 28 28 #import <WebCore/IntRectHash.h> 29 29 #import <condition_variable> 30 #import <wtf/Condition.h> 31 #import <wtf/Lock.h> 30 32 #import <wtf/RetainPtr.h> 31 33 #import <wtf/Vector.h> … … 58 60 59 61 BOOL _isPrintingFromSecondaryThread; 60 std::mutex_printingCallbackMutex;61 std::condition_variable_printingCallbackCondition;62 Lock _printingCallbackMutex; 63 Condition _printingCallbackCondition; 62 64 63 65 NSTimer *_autodisplayResumeTimer; -
trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.mm
r187135 r188642 243 243 244 244 if (!_webFrame->page()) { 245 _printingCallbackCondition.notify _one();246 return; 247 } 248 249 std::lock_guard< std::mutex> lock(_printingCallbackMutex);245 _printingCallbackCondition.notifyOne(); 246 return; 247 } 248 249 std::lock_guard<Lock> lock(_printingCallbackMutex); 250 250 251 251 ASSERT([self _hasPageRects]); … … 279 279 view->_printedPagesData.append(data->bytes(), data->size()); 280 280 view->_expectedPrintCallback = 0; 281 view->_printingCallbackCondition.notify _one();281 view->_printingCallbackCondition.notifyOne(); 282 282 } 283 283 }); … … 358 358 359 359 WKPrintingView *view = static_cast<WKPrintingView *>(untypedContext); 360 std::lock_guard< std::mutex> lock(view->_printingCallbackMutex);360 std::lock_guard<Lock> lock(view->_printingCallbackMutex); 361 361 362 362 // We may have received page rects while a message to call this function traveled from secondary thread to main one. … … 396 396 else if (!RunLoop::isMain()) { 397 397 ASSERT(![self _isPrintingPreview]); 398 std::unique_lock< std::mutex> lock(_printingCallbackMutex);398 std::unique_lock<Lock> lock(_printingCallbackMutex); 399 399 callOnMainThread(prepareDataForPrintingOnSecondaryThread, self); 400 400 _printingCallbackCondition.wait(lock);
Note: See TracChangeset
for help on using the changeset viewer.