Changeset 188642 in webkit


Ignore:
Timestamp:
Aug 19, 2015 11:18:19 AM (9 years ago)
Author:
fpizlo@apple.com
Message:

Replace all uses of std::mutex/std::condition_variable with WTF::Lock/WTF::Condition
https://bugs.webkit.org/show_bug.cgi?id=148140

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

  • inspector/remote/RemoteInspector.h:
  • inspector/remote/RemoteInspector.mm:

(Inspector::RemoteInspector::registerDebuggable):
(Inspector::RemoteInspector::unregisterDebuggable):
(Inspector::RemoteInspector::updateDebuggable):
(Inspector::RemoteInspector::updateDebuggableAutomaticInspectCandidate):
(Inspector::RemoteInspector::sendMessageToRemoteFrontend):
(Inspector::RemoteInspector::setupFailed):
(Inspector::RemoteInspector::setupCompleted):
(Inspector::RemoteInspector::start):
(Inspector::RemoteInspector::stop):
(Inspector::RemoteInspector::setupXPCConnectionIfNeeded):
(Inspector::RemoteInspector::setParentProcessInformation):
(Inspector::RemoteInspector::xpcConnectionReceivedMessage):
(Inspector::RemoteInspector::xpcConnectionFailed):
(Inspector::RemoteInspector::pushListingSoon):
(Inspector::RemoteInspector::receivedIndicateMessage):
(Inspector::RemoteInspector::receivedProxyApplicationSetupMessage):

  • inspector/remote/RemoteInspectorXPCConnection.h:
  • inspector/remote/RemoteInspectorXPCConnection.mm:

(Inspector::RemoteInspectorXPCConnection::close):
(Inspector::RemoteInspectorXPCConnection::closeFromMessage):
(Inspector::RemoteInspectorXPCConnection::deserializeMessage):
(Inspector::RemoteInspectorXPCConnection::handleEvent):

Source/WebCore:

No new tests because no new behavior.

  • Modules/webaudio/AudioBufferSourceNode.cpp:

(WebCore::AudioBufferSourceNode::process):
(WebCore::AudioBufferSourceNode::setBuffer):

  • Modules/webaudio/AudioBufferSourceNode.h:
  • Modules/webaudio/AudioParamTimeline.cpp:

(WebCore::AudioParamTimeline::insertEvent):
(WebCore::AudioParamTimeline::cancelScheduledValues):
(WebCore::AudioParamTimeline::valueForContextTime):
(WebCore::AudioParamTimeline::valuesForTimeRange):

  • Modules/webaudio/AudioParamTimeline.h:
  • Modules/webaudio/ConvolverNode.cpp:

(WebCore::ConvolverNode::process):
(WebCore::ConvolverNode::reset):
(WebCore::ConvolverNode::setBuffer):

  • Modules/webaudio/ConvolverNode.h:
  • Modules/webaudio/MediaElementAudioSourceNode.cpp:

(WebCore::MediaElementAudioSourceNode::process):

  • Modules/webaudio/MediaElementAudioSourceNode.h:
  • Modules/webaudio/MediaStreamAudioSourceNode.cpp:

(WebCore::MediaStreamAudioSourceNode::setFormat):
(WebCore::MediaStreamAudioSourceNode::process):

  • Modules/webaudio/MediaStreamAudioSourceNode.h:
  • Modules/webaudio/OscillatorNode.cpp:

(WebCore::OscillatorNode::process):
(WebCore::OscillatorNode::setPeriodicWave):

  • Modules/webaudio/OscillatorNode.h:
  • Modules/webaudio/PannerNode.cpp:

(WebCore::PannerNode::process):
(WebCore::PannerNode::setPanningModel):

  • Modules/webaudio/PannerNode.h:
  • Modules/webaudio/WaveShaperProcessor.cpp:

(WebCore::WaveShaperProcessor::setCurve):
(WebCore::WaveShaperProcessor::setOversample):
(WebCore::WaveShaperProcessor::process):

  • Modules/webaudio/WaveShaperProcessor.h:
  • Modules/webdatabase/Database.cpp:

(WebCore::retrieveTextResultFromDatabase):
(WebCore::guidToVersionMap):
(WebCore::Database::Database):
(WebCore::Database::performOpenAndVerify):
(WebCore::Database::closeDatabase):
(WebCore::Database::getCachedVersion):
(WebCore::Database::setCachedVersion):
(WebCore::guidMutex): Deleted.

  • Modules/webdatabase/DatabaseManager.cpp:

(WebCore::DatabaseManager::existingDatabaseContextFor):
(WebCore::DatabaseManager::registerDatabaseContext):
(WebCore::DatabaseManager::unregisterDatabaseContext):
(WebCore::DatabaseManager::didConstructDatabaseContext):
(WebCore::DatabaseManager::didDestructDatabaseContext):
(WebCore::DatabaseManager::addProposedDatabase):
(WebCore::DatabaseManager::removeProposedDatabase):
(WebCore::DatabaseManager::fullPathForDatabase):
(WebCore::DatabaseManager::detailsForNameAndOrigin):

  • Modules/webdatabase/DatabaseManager.h:
  • bindings/objc/DOMInternal.mm:

(getDOMWrapper):
(addDOMWrapper):
(removeDOMWrapper):
(wrapperCacheLock): Deleted.

  • crypto/CryptoAlgorithmRegistry.cpp:

(WebCore::CryptoAlgorithmRegistry::singleton):
(WebCore::CryptoAlgorithmRegistry::CryptoAlgorithmRegistry):
(WebCore::CryptoAlgorithmRegistry::getIdentifierForName):
(WebCore::CryptoAlgorithmRegistry::nameForIdentifier):
(WebCore::CryptoAlgorithmRegistry::create):
(WebCore::CryptoAlgorithmRegistry::registerAlgorithm):
(WebCore::registryMutex): Deleted.

  • inspector/WorkerDebuggerAgent.cpp:

(WebCore::WorkerDebuggerAgent::WorkerDebuggerAgent):
(WebCore::WorkerDebuggerAgent::~WorkerDebuggerAgent):
(WebCore::WorkerDebuggerAgent::interruptAndDispatchInspectorCommands):

  • page/WheelEventTestTrigger.cpp:

(WebCore::WheelEventTestTrigger::clearAllTestDeferrals):
(WebCore::WheelEventTestTrigger::setTestCallbackAndStartNotificationTimer):
(WebCore::WheelEventTestTrigger::deferTestsForReason):
(WebCore::WheelEventTestTrigger::removeTestDeferralForReason):
(WebCore::WheelEventTestTrigger::triggerTestTimerFired):

  • page/WheelEventTestTrigger.h:
  • page/scrolling/ScrollingThread.cpp:

(WebCore::ScrollingThread::dispatch):
(WebCore::ScrollingThread::createThreadIfNeeded):
(WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread):

  • page/scrolling/ScrollingThread.h:
  • page/scrolling/mac/ScrollingThreadMac.mm:

(WebCore::ScrollingThread::initializeRunLoop):

  • platform/audio/ReverbConvolver.cpp:

(WebCore::ReverbConvolver::~ReverbConvolver):
(WebCore::ReverbConvolver::backgroundThreadEntry):
(WebCore::ReverbConvolver::process):
(WebCore::ReverbConvolver::reset):

  • platform/audio/ReverbConvolver.h:
  • platform/ios/wak/WebCoreThreadRun.cpp:
  • platform/mac/Language.mm:

(WebCore::preferredLanguages):
(+[WebLanguageChangeObserver languagePreferencesDidChange:]):
(WebCore::platformUserPreferredLanguages):
(WebCore::preferredLanguagesMutex): Deleted.

  • platform/network/cf/LoaderRunLoopCF.cpp:

(WebCore::emptyPerform):
(WebCore::runLoaderThread):
(WebCore::loaderRunLoop):
(WebCore::loaderRunLoopMutex): Deleted.
(WebCore::loaderRunLoopConditionVariable): Deleted.

  • platform/network/cf/SocketStreamHandleCFNet.cpp:

(WebCore::callOnMainThreadAndWait):

  • platform/network/curl/SocketStreamHandle.h:
  • platform/network/curl/SocketStreamHandleCurl.cpp:

(WebCore::SocketStreamHandle::platformSend):
(WebCore::SocketStreamHandle::sendData):

  • platform/sql/SQLiteDatabaseTracker.cpp:

(WebCore::SQLiteDatabaseTracker::setClient):
(WebCore::SQLiteDatabaseTracker::incrementTransactionInProgressCount):
(WebCore::SQLiteDatabaseTracker::decrementTransactionInProgressCount):
(WebCore::SQLiteDatabaseTracker::transactionInProgressMutex): Deleted.

  • platform/text/TextBreakIterator.cpp:

(WebCore::compareAndSwapNonSharedCharacterBreakIterator):

  • platform/text/TextEncodingRegistry.cpp:

(WebCore::newTextCodec):
(WebCore::atomicCanonicalTextEncodingName):
(WebCore::dumpTextEncodingNameMap):
(WebCore::encodingRegistryMutex): Deleted.

  • workers/WorkerThread.cpp:

(WebCore::workerThreads):
(WebCore::WorkerThread::workerThreadCount):
(WebCore::WorkerThread::WorkerThread):
(WebCore::WorkerThread::~WorkerThread):
(WebCore::WorkerThread::releaseFastMallocFreeMemoryInAllThreads):
(WebCore::threadSetMutex): Deleted.

Source/WebKit2:

  • NetworkProcess/cache/NetworkCacheStorage.cpp:

(WebKit::NetworkCache::Storage::traverse):

  • Platform/IPC/Connection.cpp:

(IPC::Connection::SyncMessageState::processIncomingMessage):
(IPC::Connection::SyncMessageState::dispatchMessages):
(IPC::Connection::SyncMessageState::dispatchMessageAndResetDidScheduleDispatchMessagesForConnection):
(IPC::Connection::sendMessage):
(IPC::Connection::waitForMessage):
(IPC::Connection::processIncomingMessage):
(IPC::Connection::installIncomingSyncMessageCallback):
(IPC::Connection::uninstallIncomingSyncMessageCallback):
(IPC::Connection::hasIncomingSyncMessage):
(IPC::Connection::connectionDidClose):
(IPC::Connection::sendOutgoingMessages):
(IPC::Connection::enqueueIncomingMessage):
(IPC::Connection::dispatchOneMessage):

  • Platform/IPC/Connection.h:
  • Shared/BlockingResponseMap.h:

(BlockingResponseMap::waitForResponse):
(BlockingResponseMap::didReceiveResponse):
(BlockingResponseMap::cancel):

  • UIProcess/Plugins/gtk/PluginInfoCache.cpp:

(WebKit::PluginInfoCache::saveToFile):
(WebKit::PluginInfoCache::updatePluginInfo):

  • UIProcess/Plugins/gtk/PluginInfoCache.h:
  • UIProcess/mac/WKPrintingView.h:
  • UIProcess/mac/WKPrintingView.mm:

(-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]):
(prepareDataForPrintingOnSecondaryThread):
(-[WKPrintingView knowsPageRange:]):

Source/WTF:

Also beef up Condition by giving it a StaticCondition variant.

  • wtf/Condition.h:

(WTF::ConditionBase::notifyAll):
(WTF::ConditionBase::waitForSecondsImpl):
(WTF::ConditionBase::absoluteFromRelative):
(WTF::Condition::Condition):
(WTF::Condition::notifyAll): Deleted.
(WTF::Condition::waitForSecondsImpl): Deleted.
(WTF::Condition::absoluteFromRelative): Deleted.

  • wtf/CryptographicallyRandomNumber.cpp:
  • wtf/HashTable.cpp:

(WTF::HashTableStats::recordCollisionAtCount):
(WTF::HashTableStats::dumpStats):
(WTF::hashTableStatsMutex): Deleted.

  • wtf/HashTable.h:

(WTF::KeyTraits>::HashTable):
(WTF::KeyTraits>::invalidateIterators):
(WTF::addIterator):
(WTF::removeIterator):

  • wtf/Lock.h:
  • wtf/MainThread.cpp:

(WTF::functionQueue):
(WTF::dispatchFunctionsFromMainThread):
(WTF::callOnMainThread):
(WTF::cancelCallOnMainThread):
(WTF::mainThreadFunctionQueueMutex): Deleted.

  • wtf/StackStats.cpp:

(WTF::StackStats::PerThreadStats::PerThreadStats):
(WTF::StackStats::CheckPoint::CheckPoint):
(WTF::StackStats::CheckPoint::~CheckPoint):
(WTF::StackStats::probe):
(WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
(WTF::StackStats::LayoutCheckPoint::~LayoutCheckPoint):
(WTF::StackStats::initialize): Deleted.

  • wtf/StackStats.h:

(WTF::StackStats::LayoutCheckPoint::LayoutCheckPoint):
(WTF::StackStats::probe):
(WTF::StackStats::initialize): Deleted.

  • wtf/ThreadingPthreads.cpp:

(WTF::initializeThreading):

  • wtf/mac/DeprecatedSymbolsUsedBySafari.mm:

(WTF::callOnMainThread):
(WTF::lockAtomicallyInitializedStaticMutex):
(WTF::unlockAtomicallyInitializedStaticMutex):
(WTF::atomicallyInitializedStaticMutex): Deleted.

  • wtf/text/StringView.cpp:

(WTF::StringView::UnderlyingString::UnderlyingString):
(WTF::underlyingStrings):
(WTF::StringView::invalidate):
(WTF::StringView::adoptUnderlyingString):
(WTF::StringView::setUnderlyingString):
(WTF::underlyingStringsMutex): Deleted.

  • wtf/unicode/icu/CollatorICU.cpp:

(WTF::Collator::Collator):
(WTF::Collator::~Collator):
(WTF::cachedCollatorMutex): Deleted.

Location:
trunk/Source
Files:
67 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r188631 r188642  
     12015-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
    1332015-08-18  Joseph Pecoraro  <pecoraro@apple.com>
    234
  • trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h

    r179409 r188642  
    3232#import <wtf/Forward.h>
    3333#import <wtf/HashMap.h>
     34#import <wtf/Lock.h>
    3435#import <wtf/RetainPtr.h>
    3536
     
    109110    // So lock access to all maps and state as they can change
    110111    // from any thread.
    111     std::mutex m_mutex;
     112    Lock m_mutex;
    112113
    113114    HashMap<unsigned, std::pair<RemoteInspectorDebuggable*, RemoteInspectorDebuggableInfo>> m_debuggableMap;
  • trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm

    r183590 r188642  
    132132void RemoteInspector::registerDebuggable(RemoteInspectorDebuggable* debuggable)
    133133{
    134     std::lock_guard<std::mutex> lock(m_mutex);
     134    std::lock_guard<Lock> lock(m_mutex);
    135135
    136136    unsigned identifier = nextAvailableIdentifier();
     
    146146void RemoteInspector::unregisterDebuggable(RemoteInspectorDebuggable* debuggable)
    147147{
    148     std::lock_guard<std::mutex> lock(m_mutex);
     148    std::lock_guard<Lock> lock(m_mutex);
    149149
    150150    unsigned identifier = debuggable->identifier();
     
    164164void RemoteInspector::updateDebuggable(RemoteInspectorDebuggable* debuggable)
    165165{
    166     std::lock_guard<std::mutex> lock(m_mutex);
     166    std::lock_guard<Lock> lock(m_mutex);
    167167
    168168    unsigned identifier = debuggable->identifier();
     
    179179{
    180180    {
    181         std::lock_guard<std::mutex> lock(m_mutex);
     181        std::lock_guard<Lock> lock(m_mutex);
    182182
    183183        unsigned identifier = debuggable->identifier();
     
    214214        // In case debuggers fail to respond, or we cannot connect to webinspectord, automatically continue after a short period of time.
    215215        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);
    217217            if (m_automaticInspectionCandidateIdentifier == identifier) {
    218218                LOG_ERROR("Skipping Automatic Inspection Candidate with pageId(%u) because we failed to receive a response in time.", m_automaticInspectionCandidateIdentifier);
     
    225225
    226226    {
    227         std::lock_guard<std::mutex> lock(m_mutex);
     227        std::lock_guard<Lock> lock(m_mutex);
    228228
    229229        ASSERT(m_automaticInspectionCandidateIdentifier);
     
    246246void RemoteInspector::sendMessageToRemoteFrontend(unsigned identifier, const String& message)
    247247{
    248     std::lock_guard<std::mutex> lock(m_mutex);
     248    std::lock_guard<Lock> lock(m_mutex);
    249249
    250250    if (!m_xpcConnection)
     
    266266void RemoteInspector::setupFailed(unsigned identifier)
    267267{
    268     std::lock_guard<std::mutex> lock(m_mutex);
     268    std::lock_guard<Lock> lock(m_mutex);
    269269
    270270    m_connectionMap.remove(identifier);
     
    280280void RemoteInspector::setupCompleted(unsigned identifier)
    281281{
    282     std::lock_guard<std::mutex> lock(m_mutex);
     282    std::lock_guard<Lock> lock(m_mutex);
    283283
    284284    if (identifier == m_automaticInspectionCandidateIdentifier)
     
    294294void RemoteInspector::start()
    295295{
    296     std::lock_guard<std::mutex> lock(m_mutex);
     296    std::lock_guard<Lock> lock(m_mutex);
    297297
    298298    if (m_enabled)
     
    316316void RemoteInspector::stop()
    317317{
    318     std::lock_guard<std::mutex> lock(m_mutex);
     318    std::lock_guard<Lock> lock(m_mutex);
    319319
    320320    stopInternal(StopSource::API);
     
    356356void RemoteInspector::setupXPCConnectionIfNeeded()
    357357{
    358     std::lock_guard<std::mutex> lock(m_mutex);
     358    std::lock_guard<Lock> lock(m_mutex);
    359359
    360360    if (m_xpcConnection)
     
    381381void RemoteInspector::setParentProcessInformation(pid_t pid, RetainPtr<CFDataRef> auditData)
    382382{
    383     std::lock_guard<std::mutex> lock(m_mutex);
     383    std::lock_guard<Lock> lock(m_mutex);
    384384
    385385    if (m_parentProcessIdentifier || m_parentProcessAuditData)
     
    397397void RemoteInspector::xpcConnectionReceivedMessage(RemoteInspectorXPCConnection*, NSString *messageName, NSDictionary *userInfo)
    398398{
    399     std::lock_guard<std::mutex> lock(m_mutex);
     399    std::lock_guard<Lock> lock(m_mutex);
    400400
    401401    if ([messageName isEqualToString:WIRPermissionDenied]) {
     
    428428void RemoteInspector::xpcConnectionFailed(RemoteInspectorXPCConnection* connection)
    429429{
    430     std::lock_guard<std::mutex> lock(m_mutex);
     430    std::lock_guard<Lock> lock(m_mutex);
    431431
    432432    ASSERT(connection == m_xpcConnection);
     
    523523    m_pushScheduled = true;
    524524    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);
    526526        if (m_pushScheduled)
    527527            pushListingNow();
     
    650650        RemoteInspectorDebuggable* debuggable = nullptr;
    651651        {
    652             std::lock_guard<std::mutex> lock(m_mutex);
     652            std::lock_guard<Lock> lock(m_mutex);
    653653
    654654            auto it = m_debuggableMap.find(identifier);
     
    673673        m_shouldSendParentProcessInformation = true;
    674674        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);
    676676            if (m_shouldSendParentProcessInformation)
    677677                stopInternal(StopSource::XPCMessage);
  • trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.h

    r174220 r188642  
    3030
    3131#import <dispatch/dispatch.h>
    32 #import <mutex>
     32#import <wtf/Lock.h>
    3333#import <wtf/ThreadSafeRefCounted.h>
    3434#import <wtf/spi/darwin/XPCSPI.h>
     
    6363    // We handle XPC events on the queue, but a client may call close() on any queue.
    6464    // We make sure that m_client is thread safe and immediately cleared in close().
    65     std::mutex m_mutex;
     65    Lock m_mutex;
    6666
    6767    xpc_connection_t m_connection;
  • trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorXPCConnection.mm

    r181992 r188642  
    3030
    3131#import <Foundation/Foundation.h>
     32#import <mutex>
    3233#import <wtf/Assertions.h>
     34#import <wtf/Lock.h>
    3335#import <wtf/Ref.h>
    3436#import <wtf/RetainPtr.h>
     
    8082void RemoteInspectorXPCConnection::close()
    8183{
    82     std::lock_guard<std::mutex> lock(m_mutex);
     84    std::lock_guard<Lock> lock(m_mutex);
    8385    closeFromMessage();
    8486}
     
    9092
    9193    dispatch_async(m_queue, ^{
    92         std::lock_guard<std::mutex> lock(m_mutex);
     94        std::lock_guard<Lock> lock(m_mutex);
    9395        // This will trigger one last XPC_ERROR_CONNECTION_INVALID event on the queue and deref us.
    9496        closeOnQueue();
     
    117119    xpc_object_t xpcDictionary = xpc_dictionary_get_value(object, RemoteInspectorXPCConnectionSerializedMessageKey);
    118120    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);
    120122        if (m_client)
    121123            m_client->xpcConnectionUnhandledMessage(this, object);
     
    132134    if (xpc_get_type(object) == XPC_TYPE_ERROR) {
    133135        {
    134             std::lock_guard<std::mutex> lock(m_mutex);
     136            std::lock_guard<Lock> lock(m_mutex);
    135137            if (m_client)
    136138                m_client->xpcConnectionFailed(this);
     
    155157    NSString *message = [dataDictionary objectForKey:RemoteInspectorXPCConnectionMessageNameKey];
    156158    NSDictionary *userInfo = [dataDictionary objectForKey:RemoteInspectorXPCConnectionUserInfoKey];
    157     std::lock_guard<std::mutex> lock(m_mutex);
     159    std::lock_guard<Lock> lock(m_mutex);
    158160    if (m_client)
    159161        m_client->xpcConnectionReceivedMessage(this, message, userInfo);
  • trunk/Source/WTF/ChangeLog

    r188633 r188642  
     12015-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
    1662015-08-18  Zan Dobersek  <zdobersek@igalia.com>
    267
  • trunk/Source/WTF/wtf/Condition.h

    r188605 r188642  
    2929#include <chrono>
    3030#include <functional>
    31 #include <mutex>
    3231#include <wtf/CurrentTime.h>
     32#include <wtf/Noncopyable.h>
    3333#include <wtf/ParkingLot.h>
    3434
    3535namespace WTF {
    3636
    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.
     48struct ConditionBase {
    3949    typedef ParkingLot::Clock Clock;
    4050   
    41     Condition()
    42     {
    43         m_hasWaiters.store(false);
    44     }
    45 
    4651    // Wait on a parking queue while releasing the given lock. It will unlock the lock just before
    4752    // parking, and relock it upon wakeup. Returns true if we woke up due to some call to
     
    173178    }
    174179   
    175 private:
     180protected:
    176181    template<typename LockType>
    177182    bool waitForSecondsImpl(LockType& lock, double relativeTimeoutSeconds)
     
    225230
    226231    Atomic<bool> m_hasWaiters;
     232};   
     233
     234class Condition : public ConditionBase {
     235    WTF_MAKE_NONCOPYABLE(Condition);
     236public:
     237    Condition()
     238    {
     239        m_hasWaiters.store(false);
     240    }
    227241};
    228242
     243typedef ConditionBase StaticCondition;
     244
    229245} // namespace WTF
    230246
    231247using WTF::Condition;
     248using WTF::StaticCondition;
    232249
    233250#endif // WTF_Condition_h
  • trunk/Source/WTF/wtf/CryptographicallyRandomNumber.cpp

    r162935 r188642  
    3434#include "OSRandomSource.h"
    3535#include <mutex>
     36#include <wtf/Lock.h>
    3637
    3738namespace WTF {
     
    6566    ARC4Stream m_stream;
    6667    int m_count;
    67     std::mutex m_mutex;
     68    Lock m_mutex;
    6869};
    6970
     
    137138uint32_t ARC4RandomNumberGenerator::randomNumber()
    138139{
    139     std::lock_guard<std::mutex> lock(m_mutex);
     140    std::lock_guard<Lock> lock(m_mutex);
    140141
    141142    m_count -= 4;
     
    146147void ARC4RandomNumberGenerator::randomValues(void* buffer, size_t length)
    147148{
    148     std::lock_guard<std::mutex> lock(m_mutex);
     149    std::lock_guard<Lock> lock(m_mutex);
    149150
    150151    unsigned char* result = reinterpret_cast<unsigned char*>(buffer);
  • trunk/Source/WTF/wtf/HashTable.cpp

    r162774 r188642  
    3737unsigned HashTableStats::maxCollisions;
    3838
    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 }
     39static StaticLock hashTableStatsMutex;
    4940
    5041void HashTableStats::recordCollisionAtCount(unsigned count)
    5142{
    52     std::lock_guard<std::mutex> lock(hashTableStatsMutex());
     43    std::lock_guard<StaticLock> lock(hashTableStatsMutex);
    5344
    5445    if (count > maxCollisions)
     
    6051void HashTableStats::dumpStats()
    6152{
    62     std::lock_guard<std::mutex> lock(hashTableStatsMutex());
     53    std::lock_guard<StaticLock> lock(hashTableStatsMutex);
    6354
    6455    dataLogF("\nWTF::HashTable statistics\n\n");
  • trunk/Source/WTF/wtf/HashTable.h

    r187733 r188642  
    11/*
    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.
    33 * Copyright (C) 2008 David Levin <levin@chromium.org>
    44 *
     
    3131#include <wtf/FastMalloc.h>
    3232#include <wtf/HashTraits.h>
     33#include <wtf/Lock.h>
    3334#include <wtf/MathExtras.h>
    3435#include <wtf/StdLibExtras.h>
     
    487488        mutable const_iterator* m_iterators;
    488489        // 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;
    490491#endif
    491492
     
    543544#if CHECK_HASHTABLE_ITERATORS
    544545        , m_iterators(0)
    545         , m_mutex(std::make_unique<std::mutex>())
     546        , m_mutex(std::make_unique<Lock>())
    546547#endif
    547548#if DUMP_HASHTABLE_STATS_PER_TABLE
     
    12191220#if CHECK_HASHTABLE_ITERATORS
    12201221        , m_iterators(nullptr)
    1221         , m_mutex(std::make_unique<std::mutex>())
     1222        , m_mutex(std::make_unique<Lock>())
    12221223#endif
    12231224#if DUMP_HASHTABLE_STATS_PER_TABLE
     
    12771278#if CHECK_HASHTABLE_ITERATORS
    12781279        : m_iterators(nullptr)
    1279         , m_mutex(std::make_unique<std::mutex>())
     1280        , m_mutex(std::make_unique<Lock>())
    12801281#endif
    12811282    {
     
    13571358    void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::invalidateIterators()
    13581359    {
    1359         std::lock_guard<std::mutex> lock(*m_mutex);
     1360        std::lock_guard<Lock> lock(*m_mutex);
    13601361        const_iterator* next;
    13611362        for (const_iterator* p = m_iterators; p; p = next) {
     
    13791380            it->m_next = 0;
    13801381        } else {
    1381             std::lock_guard<std::mutex> lock(*table->m_mutex);
     1382            std::lock_guard<Lock> lock(*table->m_mutex);
    13821383            ASSERT(table->m_iterators != it);
    13831384            it->m_next = table->m_iterators;
     
    13981399            ASSERT(!it->m_previous);
    13991400        } else {
    1400             std::lock_guard<std::mutex> lock(*it->m_table->m_mutex);
     1401            std::lock_guard<Lock> lock(*it->m_table->m_mutex);
    14011402            if (it->m_next) {
    14021403                ASSERT(it->m_next->m_previous == it);
  • trunk/Source/WTF/wtf/Lock.h

    r188499 r188642  
    126126} // namespace WTF
    127127
    128 using WTF::StaticLock;
    129128using WTF::Lock;
    130129using WTF::LockHolder;
     130using WTF::StaticLock;
    131131
    132132#endif // WTF_Lock_h
  • trunk/Source/WTF/wtf/MainThread.cpp

    r183746 r188642  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3535#include "Threading.h"
    3636#include <mutex>
     37#include <wtf/Lock.h>
    3738#include <wtf/NeverDestroyed.h>
    3839#include <wtf/ThreadSpecific.h>
     
    7071#endif
    7172
    72 static std::mutex& mainThreadFunctionQueueMutex()
    73 {
    74     static NeverDestroyed<std::mutex> mutex;
    75    
    76     return mutex;
    77 }
     73static StaticLock mainThreadFunctionQueueMutex;
    7874
    7975static FunctionQueue& functionQueue()
     
    9591    mainThreadIdentifier = currentThread();
    9692
    97     mainThreadFunctionQueueMutex();
    9893    initializeMainThreadPlatform();
    9994    initializeGCThreads();
     
    106101static void initializeMainThreadOnce()
    107102{
    108     mainThreadFunctionQueueMutex();
    109103    initializeMainThreadPlatform();
    110104}
     
    118112static void initializeMainThreadToProcessMainThreadOnce()
    119113{
    120     mainThreadFunctionQueueMutex();
    121114    initializeMainThreadToProcessMainThreadPlatform();
    122115}
     
    157150    while (true) {
    158151        {
    159             std::lock_guard<std::mutex> lock(mainThreadFunctionQueueMutex());
     152            std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex);
    160153            if (!functionQueue().size())
    161154                break;
     
    181174    bool needToSchedule = false;
    182175    {
    183         std::lock_guard<std::mutex> lock(mainThreadFunctionQueueMutex());
     176        std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex);
    184177        needToSchedule = functionQueue().size() == 0;
    185178        functionQueue().append(FunctionWithContext(function, context));
     
    193186    ASSERT(function);
    194187
    195     std::lock_guard<std::mutex> lock(mainThreadFunctionQueueMutex());
     188    std::lock_guard<StaticLock> lock(mainThreadFunctionQueueMutex);
    196189
    197190    FunctionWithContextFinder pred(FunctionWithContext(function, context));
  • trunk/Source/WTF/wtf/StackStats.cpp

    r162939 r188642  
    4343
    4444// CheckPoint management:
    45 std::mutex* StackStats::s_sharedMutex = 0;
     45StaticLock StackStats::s_sharedMutex;
    4646StackStats::CheckPoint* StackStats::s_topCheckPoint = 0;
    4747StackStats::LayoutCheckPoint* StackStats::s_firstLayoutCheckPoint = 0;
     
    5858
    5959
    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 
    6760StackStats::PerThreadStats::PerThreadStats()
    6861{
     
    7770StackStats::CheckPoint::CheckPoint()
    7871{
    79     std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
     72    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
    8073    WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
    8174    StackStats::PerThreadStats& t = threadData->stackStats();
     
    135128StackStats::CheckPoint::~CheckPoint()
    136129{
    137     std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
     130    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
    138131    WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
    139132    StackStats::PerThreadStats& t = threadData->stackStats();
     
    166159void StackStats::probe()
    167160{
    168     std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
     161    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
    169162    WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
    170163    StackStats::PerThreadStats& t = threadData->stackStats();
     
    227220    StackStats::probe();
    228221
    229     std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
     222    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
    230223    WTFThreadData* threadData = const_cast<WTFThreadData*>(&wtfThreadData());
    231224    StackStats::PerThreadStats& t = threadData->stackStats();
     
    296289StackStats::LayoutCheckPoint::~LayoutCheckPoint()
    297290{
    298     std::lock_guard<std::mutex> lock(*StackStats::s_sharedMutex);
     291    std::lock_guard<StaticLock> lock(StackStats::s_sharedMutex);
    299292
    300293    // Pop to the previous layout checkpoint:
  • trunk/Source/WTF/wtf/StackStats.h

    r162939 r188642  
    2929#include "ExportMacros.h"
    3030#include <mutex>
     31#include <wtf/Lock.h>
    3132
    3233
     
    6869    };
    6970
    70     static void initialize() { }
    7171    static void probe() { }
    7272};
     
    110110    };
    111111
    112     // Initializes locks and the log file. Should only be called once.
    113     static void initialize();
    114 
    115112    // Used for probing the stack at places where we suspect to be high
    116113    // points of stack usage but are NOT check points where stack recursion
     
    125122private:
    126123    // CheckPoint management:
    127     static std::mutex* s_sharedMutex;
     124    static StaticLock s_sharedMutex;
    128125    static CheckPoint* s_topCheckPoint;
    129126    static LayoutCheckPoint* s_firstLayoutCheckPoint;
  • trunk/Source/WTF/wtf/ThreadingPthreads.cpp

    r188594 r188642  
    4040#include "HashMap.h"
    4141#include "RandomNumberSeed.h"
    42 #include "StackStats.h"
    4342#include "StdLibExtras.h"
    4443#include "ThreadFunctionInvocation.h"
     
    125124    initializeRandomNumberGenerator();
    126125    ThreadIdentifierData::initializeOnce();
    127     StackStats::initialize();
    128126    wtfThreadData();
    129127    initializeDates();
  • trunk/Source/WTF/wtf/mac/DeprecatedSymbolsUsedBySafari.mm

    r169518 r188642  
    3131#include "StdLibExtras.h"
    3232#include <mutex>
     33#include <wtf/Lock.h>
    3334
    3435// This file contains deprecated symbols that the last released version of Safari uses.
     
    4647}
    4748
    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 }
     49static StaticLock atomicallyInitializedStaticMutex;
    5850
    5951void lockAtomicallyInitializedStaticMutex()
    6052{
    61     atomicallyInitializedStaticMutex().lock();
     53    atomicallyInitializedStaticMutex.lock();
    6254}
    6355
    6456void unlockAtomicallyInitializedStaticMutex()
    6557{
    66     atomicallyInitializedStaticMutex().unlock();
     58    atomicallyInitializedStaticMutex.unlock();
    6759}
    6860
  • trunk/Source/WTF/wtf/text/StringView.cpp

    r184867 r188642  
    3030#include <mutex>
    3131#include <wtf/HashMap.h>
     32#include <wtf/Lock.h>
    3233#include <wtf/NeverDestroyed.h>
    3334#include <wtf/unicode/UTF8.h>
     
    118119}
    119120
    120 static std::mutex& underlyingStringsMutex()
    121 {
    122     static NeverDestroyed<std::mutex> mutex;
    123     return mutex;
    124 }
     121static StaticLock underlyingStringsMutex;
    125122
    126123static HashMap<const StringImpl*, StringView::UnderlyingString*>& underlyingStrings()
     
    134131    UnderlyingString* underlyingString;
    135132    {
    136         std::lock_guard<std::mutex> lock(underlyingStringsMutex());
     133        std::lock_guard<StaticLock> lock(underlyingStringsMutex);
    137134        underlyingString = underlyingStrings().take(&stringToBeDestroyed);
    138135        if (!underlyingString)
     
    153150        if (!--m_underlyingString->refCount) {
    154151            if (m_underlyingString->isValid) {
    155                 std::lock_guard<std::mutex> lock(underlyingStringsMutex());
     152                std::lock_guard<StaticLock> lock(underlyingStringsMutex);
    156153                underlyingStrings().remove(&m_underlyingString->string);
    157154            }
     
    168165        underlyingString = nullptr;
    169166    else {
    170         std::lock_guard<std::mutex> lock(underlyingStringsMutex());
     167        std::lock_guard<StaticLock> lock(underlyingStringsMutex);
    171168        auto result = underlyingStrings().add(string, nullptr);
    172169        if (result.isNewEntry)
  • trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp

    r179245 r188642  
    3636#include <mutex>
    3737#include <unicode/ucol.h>
     38#include <wtf/Lock.h>
    3839#include <wtf/NeverDestroyed.h>
    3940#include <wtf/StringExtras.h>
     
    5152static bool cachedCollatorShouldSortLowercaseFirst;
    5253
    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 }
     54static StaticLock cachedCollatorMutex;
    6455
    6556#if !(OS(DARWIN) && USE(CF))
     
    118109
    119110    {
    120         std::lock_guard<std::mutex> lock(cachedCollatorMutex());
     111        std::lock_guard<StaticLock> lock(cachedCollatorMutex);
    121112        if (cachedCollator && localesMatch(cachedCollatorLocale, locale) && cachedCollatorShouldSortLowercaseFirst == shouldSortLowercaseFirst) {
    122113            m_collator = cachedCollator;
     
    148139Collator::~Collator()
    149140{
    150     std::lock_guard<std::mutex> lock(cachedCollatorMutex());
     141    std::lock_guard<StaticLock> lock(cachedCollatorMutex);
    151142    if (cachedCollator) {
    152143        ucol_close(cachedCollator);
  • trunk/Source/WebCore/ChangeLog

    r188641 r188642  
     12015-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
    11402015-08-18  Wenson Hsieh  <wenson_hsieh@apple.com>
    2141
  • trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp

    r185336 r188642  
    9595
    9696    // 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);
    9898    if (!lock.owns_lock()) {
    9999        // Too bad - the try_lock() failed. We must be in the middle of changing buffers and were already outputting silence anyway.
     
    417417   
    418418    // This synchronizes with process().
    419     std::lock_guard<std::mutex> lock(m_processMutex);
     419    std::lock_guard<Lock> lock(m_processMutex);
    420420   
    421421    if (buffer) {
  • trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h

    r177733 r188642  
    3333#include "PannerNode.h"
    3434#include <memory>
    35 #include <mutex>
     35#include <wtf/Lock.h>
    3636#include <wtf/PassRefPtr.h>
    3737#include <wtf/RefPtr.h>
     
    160160
    161161    // This synchronizes process() with setBuffer() which can cause dynamic channel count changes.
    162     mutable std::mutex m_processMutex;
     162    mutable Lock m_processMutex;
    163163};
    164164
  • trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp

    r185316 r188642  
    8181        return;
    8282       
    83     std::lock_guard<std::mutex> lock(m_eventsMutex);
     83    std::lock_guard<Lock> lock(m_eventsMutex);
    8484   
    8585    unsigned i = 0;
     
    103103void AudioParamTimeline::cancelScheduledValues(float startTime)
    104104{
    105     std::lock_guard<std::mutex> lock(m_eventsMutex);
     105    std::lock_guard<Lock> lock(m_eventsMutex);
    106106
    107107    // Remove all events starting at startTime.
     
    119119
    120120    {
    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);
    122122        if (!lock.owns_lock() || !context || !m_events.size() || context->currentTime() < m_events[0].time()) {
    123123            hasValue = false;
     
    141141{
    142142    // 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);
    144144    if (!lock.owns_lock()) {
    145145        if (values) {
  • trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h

    r165676 r188642  
    3131
    3232#include "AudioContext.h"
    33 #include <mutex>
    3433#include <runtime/Float32Array.h>
     34#include <wtf/Lock.h>
    3535#include <wtf/PassRefPtr.h>
    3636#include <wtf/RefCounted.h>
     
    108108    Vector<ParamEvent> m_events;
    109109
    110     std::mutex m_eventsMutex;
     110    Lock m_eventsMutex;
    111111};
    112112
  • trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp

    r170774 r188642  
    7474
    7575    // 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);
    7777    if (!lock.owns_lock()) {
    7878        // Too bad - the try_lock() failed. We must be in the middle of setting a new impulse response.
     
    9494void ConvolverNode::reset()
    9595{
    96     std::lock_guard<std::mutex> lock(m_processMutex);
     96    std::lock_guard<Lock> lock(m_processMutex);
    9797    if (m_reverb)
    9898        m_reverb->reset();
     
    146146    {
    147147        // Synchronize with process().
    148         std::lock_guard<std::mutex> lock(m_processMutex);
     148        std::lock_guard<Lock> lock(m_processMutex);
    149149        m_reverb = WTF::move(reverb);
    150150        m_buffer = buffer;
  • trunk/Source/WebCore/Modules/webaudio/ConvolverNode.h

    r177733 r188642  
    2828#include "AudioNode.h"
    2929#include <memory>
    30 #include <mutex>
     30#include <wtf/Lock.h>
    3131#include <wtf/RefPtr.h>
    3232
     
    6868
    6969    // This synchronizes dynamic changes to the convolution impulse response with process().
    70     mutable std::mutex m_processMutex;
     70    mutable Lock m_processMutex;
    7171
    7272    // Normalize the impulse response or not. Must default to true.
  • trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp

    r185336 r188642  
    113113    // If we fail to acquire the lock then the HTMLMediaElement must be in the middle of
    114114    // 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);
    116116    if (!lock.owns_lock()) {
    117117        // We failed to acquire the lock.
  • trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h

    r184940 r188642  
    3333#include "MultiChannelResampler.h"
    3434#include <memory>
    35 #include <mutex>
     35#include <wtf/Lock.h>
    3636#include <wtf/PassRefPtr.h>
    3737
     
    6868
    6969    RefPtr<HTMLMediaElement> m_mediaElement;
    70     std::mutex m_processMutex;
     70    Lock m_processMutex;
    7171
    7272    unsigned m_sourceNumberOfChannels;
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp

    r184940 r188642  
    7373
    7474        // Synchronize with process().
    75         std::lock_guard<std::mutex> lock(m_processMutex);
     75        std::lock_guard<Lock> lock(m_processMutex);
    7676
    7777        m_sourceNumberOfChannels = numberOfChannels;
     
    104104    // If we fail to acquire the lock then the MediaStream must be in the middle of
    105105    // 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);
    107107    if (!lock.owns_lock()) {
    108108        // We failed to acquire the lock.
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h

    r184940 r188642  
    3232#include "AudioSourceProviderClient.h"
    3333#include "MediaStream.h"
    34 #include <mutex>
     34#include <wtf/Lock.h>
    3535#include <wtf/PassRefPtr.h>
    3636
     
    6969    AudioSourceProvider* m_audioSourceProvider;
    7070
    71     std::mutex m_processMutex;
     71    Lock m_processMutex;
    7272
    7373    unsigned m_sourceNumberOfChannels;
  • trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp

    r185336 r188642  
    232232
    233233    // 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);
    235235    if (!lock.owns_lock()) {
    236236        // Too bad - the try_lock() failed. We must be in the middle of changing wave-tables.
     
    341341
    342342    // This synchronizes with process().
    343     std::lock_guard<std::mutex> lock(m_processMutex);
     343    std::lock_guard<Lock> lock(m_processMutex);
    344344    m_periodicWave = periodicWave;
    345345    m_type = CUSTOM;
  • trunk/Source/WebCore/Modules/webaudio/OscillatorNode.h

    r184709 r188642  
    2929#include "AudioParam.h"
    3030#include "AudioScheduledSourceNode.h"
    31 #include <mutex>
     31#include <wtf/Lock.h>
    3232#include <wtf/PassRefPtr.h>
    3333#include <wtf/RefPtr.h>
     
    9797
    9898    // This synchronizes process().
    99     mutable std::mutex m_processMutex;
     99    mutable Lock m_processMutex;
    100100
    101101    // Stores sample-accurate values calculated according to frequency and detune.
  • trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp

    r176259 r188642  
    121121
    122122    // 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);
    124124    if (!lock.owns_lock()) {
    125125        // Too bad - The try_lock() failed. We must be in the middle of changing the panner.
     
    210210        if (!m_panner.get() || model != m_panningModel) {
    211211            // This synchronizes with process().
    212             std::lock_guard<std::mutex> lock(m_pannerMutex);
     212            std::lock_guard<Lock> lock(m_pannerMutex);
    213213
    214214            m_panner = Panner::create(model, sampleRate(), m_hrtfDatabaseLoader.get());
  • trunk/Source/WebCore/Modules/webaudio/PannerNode.h

    r184940 r188642  
    3636#include "Panner.h"
    3737#include <memory>
    38 #include <mutex>
     38#include <wtf/Lock.h>
    3939
    4040namespace WebCore {
     
    162162
    163163    // Synchronize process() and setPanningModel() which can change the panner.
    164     mutable std::mutex m_pannerMutex;
     164    mutable Lock m_pannerMutex;
    165165};
    166166
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp

    r185316 r188642  
    5353{
    5454    // This synchronizes with process().
    55     std::lock_guard<std::mutex> lock(m_processMutex);
     55    std::lock_guard<Lock> lock(m_processMutex);
    5656
    5757    m_curve = curve;
     
    6161{
    6262    // This synchronizes with process().
    63     std::lock_guard<std::mutex> lock(m_processMutex);
     63    std::lock_guard<Lock> lock(m_processMutex);
    6464
    6565    m_oversample = oversample;
     
    8686
    8787    // 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);
    8989    if (!lock.owns_lock()) {
    9090        // 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  
    3030#include "AudioNode.h"
    3131#include <memory>
    32 #include <mutex>
    3332#include <runtime/Float32Array.h>
     33#include <wtf/Lock.h>
    3434#include <wtf/RefPtr.h>
    3535
     
    6767
    6868    // This synchronizes process() with setCurve().
    69     mutable std::mutex m_processMutex;
     69    mutable Lock m_processMutex;
    7070};
    7171
  • trunk/Source/WebCore/Modules/webdatabase/Database.cpp

    r188594 r188642  
    158158
    159159// 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 }
     160static StaticLock guidMutex;
    171161
    172162typedef HashMap<DatabaseGuid, String> GuidVersionMap;
     
    234224
    235225    {
    236         std::lock_guard<std::mutex> locker(guidMutex());
     226        std::lock_guard<StaticLock> locker(guidMutex);
    237227
    238228        m_guid = guidForOriginAndName(securityOrigin()->toString(), name);
     
    371361    String currentVersion;
    372362    {
    373         std::lock_guard<std::mutex> locker(guidMutex());
     363        std::lock_guard<StaticLock> locker(guidMutex);
    374364
    375365        auto entry = guidToVersionMap().find(m_guid);
     
    466456    DatabaseTracker::tracker().removeOpenDatabase(this);
    467457    {
    468         std::lock_guard<std::mutex> locker(guidMutex());
     458        std::lock_guard<StaticLock> locker(guidMutex);
    469459
    470460        auto it = guidToDatabaseMap().find(m_guid);
     
    525515String Database::getCachedVersion() const
    526516{
    527     std::lock_guard<std::mutex> locker(guidMutex());
     517    std::lock_guard<StaticLock> locker(guidMutex);
    528518
    529519    return guidToVersionMap().get(m_guid).isolatedCopy();
     
    533523{
    534524    // Update the in memory database version map.
    535     std::lock_guard<std::mutex> locker(guidMutex());
     525    std::lock_guard<StaticLock> locker(guidMutex);
    536526
    537527    updateGuidVersionMap(m_guid, actualVersion);
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.cpp

    r188061 r188642  
    108108RefPtr<DatabaseContext> DatabaseManager::existingDatabaseContextFor(ScriptExecutionContext* context)
    109109{
    110     std::lock_guard<std::mutex> lock(m_mutex);
     110    std::lock_guard<Lock> lock(m_mutex);
    111111
    112112    ASSERT(m_databaseContextRegisteredCount >= 0);
     
    139139void DatabaseManager::registerDatabaseContext(DatabaseContext* databaseContext)
    140140{
    141     std::lock_guard<std::mutex> lock(m_mutex);
     141    std::lock_guard<Lock> lock(m_mutex);
    142142
    143143    ScriptExecutionContext* context = databaseContext->scriptExecutionContext();
     
    150150void DatabaseManager::unregisterDatabaseContext(DatabaseContext* databaseContext)
    151151{
    152     std::lock_guard<std::mutex> lock(m_mutex);
     152    std::lock_guard<Lock> lock(m_mutex);
    153153
    154154    ScriptExecutionContext* context = databaseContext->scriptExecutionContext();
     
    163163void DatabaseManager::didConstructDatabaseContext()
    164164{
    165     std::lock_guard<std::mutex> lock(m_mutex);
     165    std::lock_guard<Lock> lock(m_mutex);
    166166
    167167    m_databaseContextInstanceCount++;
     
    170170void DatabaseManager::didDestructDatabaseContext()
    171171{
    172     std::lock_guard<std::mutex> lock(m_mutex);
     172    std::lock_guard<Lock> lock(m_mutex);
    173173
    174174    m_databaseContextInstanceCount--;
     
    259259void DatabaseManager::addProposedDatabase(ProposedDatabase* proposedDb)
    260260{
    261     std::lock_guard<std::mutex> lock(m_mutex);
     261    std::lock_guard<Lock> lock(m_mutex);
    262262
    263263    m_proposedDatabases.add(proposedDb);
     
    266266void DatabaseManager::removeProposedDatabase(ProposedDatabase* proposedDb)
    267267{
    268     std::lock_guard<std::mutex> lock(m_mutex);
     268    std::lock_guard<Lock> lock(m_mutex);
    269269
    270270    m_proposedDatabases.remove(proposedDb);
     
    321321{
    322322    {
    323         std::lock_guard<std::mutex> lock(m_mutex);
     323        std::lock_guard<Lock> lock(m_mutex);
    324324
    325325        for (auto* proposedDatabase : m_proposedDatabases) {
     
    350350{
    351351    {
    352         std::lock_guard<std::mutex> lock(m_mutex);
     352        std::lock_guard<Lock> lock(m_mutex);
    353353       
    354354        for (auto* proposedDatabase : m_proposedDatabases) {
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseManager.h

    r188061 r188642  
    3030#include "DatabaseDetails.h"
    3131#include "DatabaseError.h"
    32 #include <mutex>
    3332#include <wtf/Assertions.h>
    3433#include <wtf/HashMap.h>
    3534#include <wtf/HashSet.h>
     35#include <wtf/Lock.h>
    3636#include <wtf/PassRefPtr.h>
    3737#include <wtf/Threading.h>
     
    150150
    151151    // This mutex protects m_contextMap, and m_proposedDatabases.
    152     std::mutex m_mutex;
     152    Lock m_mutex;
    153153};
    154154
  • trunk/Source/WebCore/bindings/objc/DOMInternal.mm

    r176278 r188642  
    3434#import "WebScriptObjectPrivate.h"
    3535#import "runtime_root.h"
     36#import <wtf/Lock.h>
    3637#import <wtf/NeverDestroyed.h>
    3738#import <wtf/spi/cocoa/NSMapTableSPI.h>
     
    4748   
    4849#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 }
     50static StaticLock wrapperCacheLock;
    5951#endif
    6052
     
    7971{
    8072#ifdef NEEDS_WRAPPER_CACHE_LOCK
    81     std::lock_guard<std::mutex> lock(wrapperCacheLock());
     73    std::lock_guard<StaticLock> lock(wrapperCacheLock);
    8274#endif
    8375    if (!DOMWrapperCache)
     
    8981{
    9082#ifdef NEEDS_WRAPPER_CACHE_LOCK
    91     std::lock_guard<std::mutex> lock(wrapperCacheLock());
     83    std::lock_guard<StaticLock> lock(wrapperCacheLock);
    9284#endif
    9385    if (!DOMWrapperCache)
     
    9991{
    10092#ifdef NEEDS_WRAPPER_CACHE_LOCK
    101     std::lock_guard<std::mutex> lock(wrapperCacheLock());
     93    std::lock_guard<StaticLock> lock(wrapperCacheLock);
    10294#endif
    10395    if (!DOMWrapperCache)
  • trunk/Source/WebCore/crypto/CryptoAlgorithmRegistry.cpp

    r179409 r188642  
    3030
    3131#include "CryptoAlgorithm.h"
    32 #include <mutex>
     32#include <wtf/Lock.h>
    3333#include <wtf/NeverDestroyed.h>
    3434
     
    4242}
    4343
    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 }
     44static StaticLock registryMutex;
    5545
    5646CryptoAlgorithmRegistry::CryptoAlgorithmRegistry()
     
    6454        return false;
    6555
    66     std::lock_guard<std::mutex> lock(registryMutex());
     56    std::lock_guard<StaticLock> lock(registryMutex);
    6757
    6858    auto iter = m_nameToIdentifierMap.find(name.isolatedCopy());
     
    7666String CryptoAlgorithmRegistry::nameForIdentifier(CryptoAlgorithmIdentifier identifier)
    7767{
    78     std::lock_guard<std::mutex> lock(registryMutex());
     68    std::lock_guard<StaticLock> lock(registryMutex);
    7969
    8070    return m_identifierToNameMap.get(static_cast<unsigned>(identifier)).isolatedCopy();
     
    8373std::unique_ptr<CryptoAlgorithm> CryptoAlgorithmRegistry::create(CryptoAlgorithmIdentifier identifier)
    8474{
    85     std::lock_guard<std::mutex> lock(registryMutex());
     75    std::lock_guard<StaticLock> lock(registryMutex);
    8676
    8777    auto iter = m_identifierToConstructorMap.find(static_cast<unsigned>(identifier));
     
    9484void CryptoAlgorithmRegistry::registerAlgorithm(const String& name, CryptoAlgorithmIdentifier identifier, CryptoAlgorithmConstructor constructor)
    9585{
    96     std::lock_guard<std::mutex> lock(registryMutex());
     86    std::lock_guard<StaticLock> lock(registryMutex);
    9787
    9888    bool added = m_nameToIdentifierMap.add(name, identifier).isNewEntry;
  • trunk/Source/WebCore/inspector/WorkerDebuggerAgent.cpp

    r178820 r188642  
    3737#include <inspector/InjectedScriptManager.h>
    3838#include <inspector/ScriptDebugServer.h>
    39 #include <mutex>
     39#include <wtf/Lock.h>
    4040#include <wtf/MessageQueue.h>
    4141#include <wtf/NeverDestroyed.h>
     
    4747namespace {
    4848
    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 }
     49StaticLock workerDebuggerAgentsMutex;
    6050
    6151typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents;
     
    9686    , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope)
    9787{
    98     std::lock_guard<std::mutex> lock(workerDebuggerAgentsMutex());
     88    std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex);
    9989    workerDebuggerAgents().set(&inspectedWorkerGlobalScope->thread(), this);
    10090}
     
    10292WorkerDebuggerAgent::~WorkerDebuggerAgent()
    10393{
    104     std::lock_guard<std::mutex> lock(workerDebuggerAgentsMutex());
     94    std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex);
    10595
    10696    ASSERT(workerDebuggerAgents().contains(&m_inspectedWorkerGlobalScope->thread()));
     
    110100void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* thread)
    111101{
    112     std::lock_guard<std::mutex> lock(workerDebuggerAgentsMutex());
     102    std::lock_guard<StaticLock> lock(workerDebuggerAgentsMutex);
    113103
    114104    if (WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread))
  • trunk/Source/WebCore/page/WheelEventTestTrigger.cpp

    r183824 r188642  
    4646void WheelEventTestTrigger::clearAllTestDeferrals()
    4747{
    48     std::lock_guard<std::mutex> lock(m_testTriggerMutex);
     48    std::lock_guard<Lock> lock(m_testTriggerMutex);
    4949    m_deferTestTriggerReasons.clear();
    5050    m_testNotificationCallback = std::function<void()>();
     
    5656{
    5757    {
    58         std::lock_guard<std::mutex> lock(m_testTriggerMutex);
     58        std::lock_guard<Lock> lock(m_testTriggerMutex);
    5959        m_testNotificationCallback = WTF::move(functionCallback);
    6060    }
     
    6666void WheelEventTestTrigger::deferTestsForReason(ScrollableAreaIdentifier identifier, DeferTestTriggerReason reason)
    6767{
    68     std::lock_guard<std::mutex> lock(m_testTriggerMutex);
     68    std::lock_guard<Lock> lock(m_testTriggerMutex);
    6969    auto it = m_deferTestTriggerReasons.find(identifier);
    7070    if (it == m_deferTestTriggerReasons.end())
     
    7777void WheelEventTestTrigger::removeTestDeferralForReason(ScrollableAreaIdentifier identifier, DeferTestTriggerReason reason)
    7878{
    79     std::lock_guard<std::mutex> lock(m_testTriggerMutex);
     79    std::lock_guard<Lock> lock(m_testTriggerMutex);
    8080    auto it = m_deferTestTriggerReasons.find(identifier);
    8181    if (it == m_deferTestTriggerReasons.end())
     
    111111
    112112    {
    113         std::lock_guard<std::mutex> lock(m_testTriggerMutex);
     113        std::lock_guard<Lock> lock(m_testTriggerMutex);
    114114        if (!m_deferTestTriggerReasons.isEmpty()) {
    115115#if !LOG_DISABLED
  • trunk/Source/WebCore/page/WheelEventTestTrigger.h

    r183595 r188642  
    3030#define WheelEventTestTrigger_h
    3131
    32 #include <mutex>
    3332#include <set>
    3433#include <wtf/HashMap.h>
     34#include <wtf/Lock.h>
    3535#include <wtf/RefPtr.h>
    3636#include <wtf/RunLoop.h>
     
    6161    std::function<void()> m_testNotificationCallback;
    6262    RunLoop::Timer<WheelEventTestTrigger> m_testTriggerTimer;
    63     mutable std::mutex m_testTriggerMutex;
     63    mutable Lock m_testTriggerMutex;
    6464    WTF::HashMap<ScrollableAreaIdentifier, std::set<DeferTestTriggerReason>> m_deferTestTriggerReasons;
    6565};
  • trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp

    r179409 r188642  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#if ENABLE(ASYNC_SCROLLING)
    3030
     31#include <mutex>
    3132#include <wtf/MainThread.h>
    3233#include <wtf/NeverDestroyed.h>
     
    5152
    5253    {
    53         std::lock_guard<std::mutex> lock(singleton().m_functionsMutex);
     54        std::lock_guard<Lock> lock(singleton().m_functionsMutex);
    5455        scrollingThread.m_functions.append(function);
    5556    }
     
    7980    // Wait for the thread to initialize the run loop.
    8081    {
    81         std::unique_lock<std::mutex> lock(m_initializeRunLoopMutex);
     82        std::unique_lock<Lock> lock(m_initializeRunLoopMutex);
    8283
    8384        m_threadIdentifier = createThread(threadCallback, this, "WebCore: Scrolling");
     
    107108   
    108109    {
    109         std::lock_guard<std::mutex> lock(m_functionsMutex);
     110        std::lock_guard<Lock> lock(m_functionsMutex);
    110111        functions = WTF::move(m_functions);
    111112    }
  • trunk/Source/WebCore/page/scrolling/ScrollingThread.h

    r179409 r188642  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#if ENABLE(ASYNC_SCROLLING)
    3030
    31 #include <condition_variable>
    3231#include <functional>
     32#include <wtf/Condition.h>
    3333#include <wtf/Forward.h>
     34#include <wtf/Lock.h>
    3435#include <wtf/Noncopyable.h>
    3536#include <wtf/Threading.h>
     
    7576    ThreadIdentifier m_threadIdentifier;
    7677
    77     std::condition_variable m_initializeRunLoopConditionVariable;
    78     std::mutex m_initializeRunLoopMutex;
     78    Condition m_initializeRunLoopConditionVariable;
     79    Lock m_initializeRunLoopMutex;
    7980
    80     std::mutex m_functionsMutex;
     81    Lock m_functionsMutex;
    8182    Vector<std::function<void ()>> m_functions;
    8283
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingThreadMac.mm

    r169955 r188642  
    2929#if ENABLE(ASYNC_SCROLLING)
    3030
     31#include <mutex>
     32
    3133namespace WebCore {
    3234
     
    3537    // Initialize the run loop.
    3638    {
    37         std::lock_guard<std::mutex> lock(m_initializeRunLoopMutex);
     39        std::lock_guard<Lock> lock(m_initializeRunLoopMutex);
    3840
    3941        m_threadRunLoop = CFRunLoopGetCurrent();
     
    4345        CFRunLoopAddSource(CFRunLoopGetCurrent(), m_threadRunLoopSource.get(), kCFRunLoopDefaultMode);
    4446
    45         m_initializeRunLoopConditionVariable.notify_all();
     47        m_initializeRunLoopConditionVariable.notifyAll();
    4648    }
    4749
  • trunk/Source/WebCore/platform/audio/ReverbConvolver.cpp

    r170774 r188642  
    3535#include "VectorMath.h"
    3636#include "AudioBus.h"
     37#include <mutex>
    3738
    3839namespace WebCore {
     
    141142        // Wake up thread so it can return
    142143        {
    143             std::lock_guard<std::mutex> lock(m_backgroundThreadMutex);
     144            std::lock_guard<Lock> lock(m_backgroundThreadMutex);
    144145            m_moreInputBuffered = true;
    145             m_backgroundThreadConditionVariable.notify_one();
     146            m_backgroundThreadConditionVariable.notifyOne();
    146147        }
    147148
     
    156157        m_moreInputBuffered = false;       
    157158        {
    158             std::unique_lock<std::mutex> lock(m_backgroundThreadMutex);
     159            std::unique_lock<Lock> lock(m_backgroundThreadMutex);
    159160
    160161            m_backgroundThreadConditionVariable.wait(lock, [this] { return m_moreInputBuffered || m_wantsToExit; });
     
    210211    // and frequently (around every 3ms).  The background thread is processing well into the future and has a considerable amount of
    211212    // 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);
    213214    if (!lock.owns_lock())
    214215        return;
    215216
    216217    m_moreInputBuffered = true;
    217     m_backgroundThreadConditionVariable.notify_one();
     218    m_backgroundThreadConditionVariable.notifyOne();
    218219}
    219220
  • trunk/Source/WebCore/platform/audio/ReverbConvolver.h

    r165676 r188642  
    11/*
    22 * Copyright (C) 2010 Google Inc. All rights reserved.
     3 * Copyright (C) 2015 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3637#include "ReverbConvolverStage.h"
    3738#include "ReverbInputBuffer.h"
    38 #include <condition_variable>
    3939#include <memory>
    40 #include <mutex>
     40#include <wtf/Condition.h>
     41#include <wtf/Lock.h>
    4142#include <wtf/RefCounted.h>
    4243#include <wtf/Threading.h>
     
    8990    bool m_wantsToExit;
    9091    bool m_moreInputBuffered;
    91     mutable std::mutex m_backgroundThreadMutex;
    92     mutable std::condition_variable m_backgroundThreadConditionVariable;
     92    mutable Lock m_backgroundThreadMutex;
     93    mutable Condition m_backgroundThreadConditionVariable;
    9394};
    9495
  • trunk/Source/WebCore/platform/ios/wak/WebCoreThreadRun.cpp

    r162292 r188642  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3131#include "WebCoreThread.h"
    3232#include "WebCoreThreadInternal.h"
    33 #include <condition_variable>
     33#include <mutex>
     34#include <wtf/Condition.h>
     35#include <wtf/Lock.h>
    3436#include <wtf/Vector.h>
    3537
     
    4547    void waitForCompletion()
    4648    {
    47         std::unique_lock<std::mutex> lock(m_stateMutex);
     49        std::unique_lock<Lock> lock(m_stateMutex);
    4850
    4951        m_completionConditionVariable.wait(lock, [this] { return m_completed; });
     
    5254    void setCompleted()
    5355    {
    54         std::lock_guard<std::mutex> lock(m_stateMutex);
     56        std::lock_guard<Lock> lock(m_stateMutex);
    5557
    5658        ASSERT(!m_completed);
    5759        m_completed = true;
    58         m_completionConditionVariable.notify_one();
     60        m_completionConditionVariable.notifyOne();
    5961    }
    6062
    6163private:
    62     std::mutex m_stateMutex;
    63     std::condition_variable m_completionConditionVariable;
     64    Lock m_stateMutex;
     65    Condition m_completionConditionVariable;
    6466    bool m_completed;
    6567};
     
    111113typedef WTF::Vector<WebThreadBlock> WebThreadRunQueue;
    112114
    113 static std::mutex* runQueueMutex;
     115static StaticLock runQueueMutex;
    114116static CFRunLoopSourceRef runSource;
    115117static WebThreadRunQueue* runQueue;
     
    119121    UNUSED_PARAM(info);
    120122    ASSERT(WebThreadIsCurrent());
    121     ASSERT(runQueueMutex);
    122123    ASSERT(runSource);
    123124    ASSERT(runQueue);
     
    125126    WebThreadRunQueue queueCopy;
    126127    {
    127         std::lock_guard<std::mutex> lock(*runQueueMutex);
     128        std::lock_guard<StaticLock> lock(runQueueMutex);
    128129        queueCopy = *runQueue;
    129130        runQueue->clear();
     
    141142    }
    142143
    143     ASSERT(runQueueMutex);
    144144    ASSERT(runSource);
    145145    ASSERT(runQueue);
     
    150150
    151151    {
    152         std::lock_guard<std::mutex> lock(*runQueueMutex);
     152        std::lock_guard<StaticLock> lock(runQueueMutex);
    153153        runQueue->append(WebThreadBlock(task, state));
    154154    }
     
    176176{
    177177    ASSERT(!runQueue);
    178     ASSERT(!runQueueMutex);
    179178    ASSERT(!runSource);
    180179
     
    186185        runSource = CFRunLoopSourceCreate(NULL, -1, &runSourceContext);
    187186        CFRunLoopAddSource(WebThreadRunLoop(), runSource, kCFRunLoopDefaultMode);
    188 
    189         runQueueMutex = std::make_unique<std::mutex>().release();
    190187    });
    191188}
  • trunk/Source/WebCore/platform/mac/Language.mm

    r185816 r188642  
    3232#import <mutex>
    3333#import <wtf/Assertions.h>
     34#import <wtf/Lock.h>
    3435#import <wtf/NeverDestroyed.h>
    3536#import <wtf/RetainPtr.h>
     
    3839namespace WebCore {
    3940
    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 }
     41static StaticLock preferredLanguagesMutex;
    5142
    5243static Vector<String>& preferredLanguages()
     
    6859
    6960    {
    70         std::lock_guard<std::mutex> lock(WebCore::preferredLanguagesMutex());
     61        std::lock_guard<StaticLock> lock(WebCore::preferredLanguagesMutex);
    7162        WebCore::preferredLanguages().clear();
    7263    }
     
    119110    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    120111
    121     std::lock_guard<std::mutex> lock(preferredLanguagesMutex());
     112    std::lock_guard<StaticLock> lock(preferredLanguagesMutex);
    122113    Vector<String>& userPreferredLanguages = preferredLanguages();
    123114
  • trunk/Source/WebCore/platform/network/cf/LoaderRunLoopCF.cpp

    r162292 r188642  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030
    3131#include <CoreFoundation/CoreFoundation.h>
    32 #include <condition_variable>
    3332#include <limits>
     33#include <mutex>
    3434#include <wtf/AutodrainedPool.h>
     35#include <wtf/Condition.h>
     36#include <wtf/Lock.h>
    3537#include <wtf/MainThread.h>
    3638#include <wtf/NeverDestroyed.h>
     
    4143static CFRunLoopRef loaderRunLoopObject = 0;
    4244
    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 }
     45static StaticLock loaderRunLoopMutex;
     46static StaticCondition loaderRunLoopConditionVariable;
    5647
    5748static void emptyPerform(void*)
     
    6253{
    6354    {
    64         std::lock_guard<std::mutex> lock(loaderRunLoopMutex());
     55        std::lock_guard<StaticLock> lock(loaderRunLoopMutex);
    6556
    6657        loaderRunLoopObject = CFRunLoopGetCurrent();
     
    7162        CFRunLoopAddSource(loaderRunLoopObject, bogusSource, kCFRunLoopDefaultMode);
    7263
    73         loaderRunLoopConditionVariable().notify_one();
     64        loaderRunLoopConditionVariable.notifyOne();
    7465    }
    7566
     
    8576    ASSERT(isMainThread());
    8677
    87     std::unique_lock<std::mutex> lock(loaderRunLoopMutex());
     78    std::unique_lock<StaticLock> lock(loaderRunLoopMutex);
    8879
    8980    if (!loaderRunLoopObject) {
    9081        createThread(runLoaderThread, 0, "WebCore: CFNetwork Loader");
    9182
    92         loaderRunLoopConditionVariable().wait(lock, [] { return loaderRunLoopObject; });
     83        loaderRunLoopConditionVariable.wait(lock, [] { return loaderRunLoopObject; });
    9384    }
    9485
  • trunk/Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp

    r186476 r188642  
    4040#include "SocketStreamError.h"
    4141#include "SocketStreamHandleClient.h"
    42 #include <condition_variable>
    43 #include <mutex>
     42#include <wtf/Condition.h>
     43#include <wtf/Lock.h>
    4444#include <wtf/MainThread.h>
    4545#include <wtf/text/WTFString.h>
     
    137137    }
    138138
    139     std::mutex mutex;
    140     std::condition_variable conditionVariable;
     139    Lock mutex;
     140    Condition conditionVariable;
    141141
    142142    bool isFinished = false;
     
    145145        function();
    146146
    147         std::lock_guard<std::mutex> lock(mutex);
     147        std::lock_guard<Lock> lock(mutex);
    148148        isFinished = true;
    149         conditionVariable.notify_one();
     149        conditionVariable.notifyOne();
    150150    });
    151151
    152     std::unique_lock<std::mutex> lock(mutex);
     152    std::unique_lock<Lock> lock(mutex);
    153153    conditionVariable.wait(lock, [&] { return isFinished; });
    154154}
  • trunk/Source/WebCore/platform/network/curl/SocketStreamHandle.h

    r186479 r188642  
    4141#include <curl/curl.h>
    4242
    43 #include <mutex>
    44 
    4543#include <wtf/Deque.h>
     44#include <wtf/Lock.h>
    4645#include <wtf/RefCounted.h>
    4746#include <wtf/Threading.h>
     
    106105    ThreadIdentifier m_workerThread { 0 };
    107106    std::atomic<bool> m_stopThread { false };
    108     std::mutex m_mutexSend;
    109     std::mutex m_mutexReceive;
     107    Lock m_mutexSend;
     108    Lock m_mutexReceive;
    110109    Deque<SocketData> m_sendData;
    111110    Deque<SocketData> m_receiveData;
  • trunk/Source/WebCore/platform/network/curl/SocketStreamHandleCurl.cpp

    r184389 r188642  
    6868    auto copy = createCopy(data, length);
    6969
    70     std::lock_guard<std::mutex> lock(m_mutexSend);
     70    std::lock_guard<Lock> lock(m_mutexSend);
    7171    m_sendData.append(SocketData { WTF::move(copy), length });
    7272
     
    147147            auto copy = createCopy(sendData.data.get() + totalBytesSent, restLength);
    148148
    149             std::lock_guard<std::mutex> lock(m_mutexSend);
     149            std::lock_guard<Lock> lock(m_mutexSend);
    150150            m_sendData.prepend(SocketData { WTF::move(copy), restLength });
    151151
  • trunk/Source/WebCore/platform/sql/SQLiteDatabaseTracker.cpp

    r162787 r188642  
    2828
    2929#include <mutex>
    30 #include <wtf/NeverDestroyed.h>
     30#include <wtf/Lock.h>
    3131
    3232namespace WebCore {
     
    3737static unsigned s_transactionInProgressCounter = 0;
    3838
    39 static std::mutex& transactionInProgressMutex()
    40 {
    41     static NeverDestroyed<std::mutex> tipMutex;
    42     return tipMutex;
    43 }
     39static StaticLock transactionInProgressMutex;
    4440
    4541void setClient(SQLiteDatabaseTrackerClient* client)
     
    5551        return;
    5652
    57     std::lock_guard<std::mutex> lock(transactionInProgressMutex());
     53    std::lock_guard<StaticLock> lock(transactionInProgressMutex);
    5854
    5955    s_transactionInProgressCounter++;
     
    6763        return;
    6864
    69     std::lock_guard<std::mutex> lock(transactionInProgressMutex());
     65    std::lock_guard<StaticLock> lock(transactionInProgressMutex);
    7066
    7167    ASSERT(s_transactionInProgressCounter);
  • trunk/Source/WebCore/platform/text/TextBreakIterator.cpp

    r181351 r188642  
    2828#include <mutex>
    2929#include <wtf/Atomics.h>
     30#include <wtf/Lock.h>
    3031#include <wtf/text/StringView.h>
    3132
     
    766767    return WTF::weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), expected, newValue);
    767768#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);
    770771    if (nonSharedCharacterBreakIterator != expected)
    771772        return false;
  • trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp

    r174757 r188642  
    3838#include <wtf/HashMap.h>
    3939#include <wtf/HashSet.h>
     40#include <wtf/Lock.h>
    4041#include <wtf/MainThread.h>
    4142#include <wtf/NeverDestroyed.h>
     
    107108typedef HashMap<const char*, TextCodecFactory> TextCodecMap;
    108109
    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 }
     110static StaticLock encodingRegistryMutex;
    117111
    118112static TextEncodingNameMap* textEncodingNameMap;
     
    295289std::unique_ptr<TextCodec> newTextCodec(const TextEncoding& encoding)
    296290{
    297     std::lock_guard<std::mutex> lock(encodingRegistryMutex());
     291    std::lock_guard<StaticLock> lock(encodingRegistryMutex);
    298292
    299293    ASSERT(textCodecMap);
     
    311305        buildBaseTextCodecMaps();
    312306
    313     std::lock_guard<std::mutex> lock(encodingRegistryMutex());
     307    std::lock_guard<StaticLock> lock(encodingRegistryMutex);
    314308
    315309    if (const char* atomicName = textEncodingNameMap->get(name))
     
    378372    fprintf(stderr, "Dumping %u entries in WebCore::textEncodingNameMap...\n", size);
    379373
    380     std::lock_guard<std::mutex> lock(encodingRegistryMutex());
     374    std::lock_guard<StaticLock> lock(encodingRegistryMutex);
    381375
    382376    TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin();
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r188594 r188642  
    3636#include "URL.h"
    3737#include <utility>
     38#include <wtf/Lock.h>
    3839#include <wtf/NeverDestroyed.h>
    3940#include <wtf/Noncopyable.h>
     
    4748namespace WebCore {
    4849
    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 }
     50static StaticLock threadSetMutex;
    6051
    6152static HashSet<WorkerThread*>& workerThreads()
     
    6859unsigned WorkerThread::workerThreadCount()
    6960{
    70     std::lock_guard<std::mutex> lock(threadSetMutex());
     61    std::lock_guard<StaticLock> lock(threadSetMutex);
    7162
    7263    return workerThreads().size();
     
    10798#endif
    10899{
    109     std::lock_guard<std::mutex> lock(threadSetMutex());
     100    std::lock_guard<StaticLock> lock(threadSetMutex);
    110101
    111102    workerThreads().add(this);
     
    114105WorkerThread::~WorkerThread()
    115106{
    116     std::lock_guard<std::mutex> lock(threadSetMutex());
     107    std::lock_guard<StaticLock> lock(threadSetMutex);
    117108
    118109    ASSERT(workerThreads().contains(this));
     
    222213void WorkerThread::releaseFastMallocFreeMemoryInAllThreads()
    223214{
    224     std::lock_guard<std::mutex> lock(threadSetMutex());
     215    std::lock_guard<StaticLock> lock(threadSetMutex);
    225216
    226217    for (auto* workerThread : workerThreads()) {
  • trunk/Source/WebKit2/ChangeLog

    r188640 r188642  
     12015-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
    1392015-08-19  Chris Dumez  <cdumez@apple.com>
    240
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp

    r188640 r188642  
    3333#include "NetworkCacheFileSystem.h"
    3434#include "NetworkCacheIOChannel.h"
    35 #include <condition_variable>
     35#include <mutex>
     36#include <wtf/Condition.h>
     37#include <wtf/Lock.h>
    3638#include <wtf/RandomNumber.h>
    3739#include <wtf/RunLoop.h>
     
    120122    const TraverseHandler handler;
    121123
    122     std::mutex activeMutex;
    123     std::condition_variable activeCondition;
     124    Lock activeMutex;
     125    Condition activeCondition;
    124126    unsigned activeCount { 0 };
    125127};
     
    792794                bodyShareCount = m_blobStorage.shareCount(bodyPathForRecordPath(recordPath));
    793795
    794             std::unique_lock<std::mutex> lock(traverseOperation.activeMutex);
     796            std::unique_lock<Lock> lock(traverseOperation.activeMutex);
    795797            ++traverseOperation.activeCount;
    796798
     
    815817                }
    816818
    817                 std::lock_guard<std::mutex> lock(traverseOperation.activeMutex);
     819                std::lock_guard<Lock> lock(traverseOperation.activeMutex);
    818820                --traverseOperation.activeCount;
    819                 traverseOperation.activeCondition.notify_one();
     821                traverseOperation.activeCondition.notifyOne();
    820822            });
    821823
     
    826828        });
    827829        // Wait for all reads to finish.
    828         std::unique_lock<std::mutex> lock(traverseOperation.activeMutex);
     830        std::unique_lock<Lock> lock(traverseOperation.activeMutex);
    829831        traverseOperation.activeCondition.wait(lock, [&traverseOperation] {
    830832            return !traverseOperation.activeCount;
  • trunk/Source/WebKit2/Platform/IPC/Connection.cpp

    r188594 r188642  
    8787
    8888    // Protects m_didScheduleDispatchMessagesWorkSet and m_messagesToDispatchWhileWaitingForSyncReply.
    89     std::mutex m_mutex;
     89    Lock m_mutex;
    9090
    9191    // The set of connections for which we've scheduled a call to dispatchMessageAndResetDidScheduleDispatchMessagesForConnection.
     
    132132
    133133    {
    134         std::lock_guard<std::mutex> lock(m_mutex);
     134        std::lock_guard<Lock> lock(m_mutex);
    135135       
    136136        if (m_didScheduleDispatchMessagesWorkSet.add(&connection).isNewEntry) {
     
    156156
    157157    {
    158         std::lock_guard<std::mutex> lock(m_mutex);
     158        std::lock_guard<Lock> lock(m_mutex);
    159159        m_messagesToDispatchWhileWaitingForSyncReply.swap(messagesToDispatchWhileWaitingForSyncReply);
    160160    }
     
    176176
    177177    if (!messagesToPutBack.isEmpty()) {
    178         std::lock_guard<std::mutex> lock(m_mutex);
     178        std::lock_guard<Lock> lock(m_mutex);
    179179
    180180        for (auto& message : messagesToPutBack)
     
    186186{
    187187    {
    188         std::lock_guard<std::mutex> lock(m_mutex);
     188        std::lock_guard<Lock> lock(m_mutex);
    189189        ASSERT(m_didScheduleDispatchMessagesWorkSet.contains(&connection));
    190190        m_didScheduleDispatchMessagesWorkSet.remove(&connection);
     
    364364
    365365    {
    366         std::lock_guard<std::mutex> lock(m_outgoingMessagesMutex);
     366        std::lock_guard<Lock> lock(m_outgoingMessagesMutex);
    367367        m_outgoingMessages.append(WTF::move(encoder));
    368368    }
     
    389389    // First, check if this message is already in the incoming messages queue.
    390390    {
    391         std::lock_guard<std::mutex> lock(m_incomingMessagesMutex);
     391        std::lock_guard<Lock> lock(m_incomingMessagesMutex);
    392392
    393393        for (auto it = m_incomingMessages.begin(), end = m_incomingMessages.end(); it != end; ++it) {
     
    415415
    416416    {
    417         std::lock_guard<std::mutex> lock(m_waitForMessageMutex);
     417        std::lock_guard<Lock> lock(m_waitForMessageMutex);
    418418
    419419        // We don't support having multiple clients waiting for messages.
     
    424424
    425425    // Now wait for it to be set.
     426    Condition::Clock::time_point absoluteTimeout = Condition::Clock::now() + timeout;
    426427    while (true) {
    427         std::unique_lock<std::mutex> lock(m_waitForMessageMutex);
     428        std::unique_lock<Lock> lock(m_waitForMessageMutex);
    428429
    429430        if (m_waitingForMessage->decoder) {
     
    434435
    435436        // Now we wait.
    436         std::cv_status status = m_waitForMessageCondition.wait_for(lock, timeout);
     437        bool didTimeout = !m_waitForMessageCondition.waitUntil(lock, absoluteTimeout);
    437438        // 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)
    439440            break;
    440441    }
     
    671672
    672673    if (message->isSyncMessage()) {
    673         std::lock_guard<std::mutex> lock(m_incomingSyncMessageCallbackMutex);
     674        std::lock_guard<Lock> lock(m_incomingSyncMessageCallbackMutex);
    674675
    675676        for (auto& callback : m_incomingSyncMessageCallbacks.values())
     
    687688    // Check if we're waiting for this message.
    688689    {
    689         std::lock_guard<std::mutex> lock(m_waitForMessageMutex);
     690        std::lock_guard<Lock> lock(m_waitForMessageMutex);
    690691
    691692        if (m_waitingForMessage && m_waitingForMessage->messageReceiverName == message->messageReceiverName() && m_waitingForMessage->messageName == message->messageName() && m_waitingForMessage->destinationID == message->destinationID()) {
    692693            m_waitingForMessage->decoder = WTF::move(message);
    693694            ASSERT(m_waitingForMessage->decoder);
    694             m_waitForMessageCondition.notify_one();
     695            m_waitForMessageCondition.notifyOne();
    695696            return;
    696697        }
     
    698699        if (m_waitingForMessage && (m_waitingForMessage->waitForMessageFlags & InterruptWaitingIfSyncMessageArrives) && message->isSyncMessage()) {
    699700            m_waitingForMessage->messageWaitingInterrupted = true;
    700             m_waitForMessageCondition.notify_one();
     701            m_waitForMessageCondition.notifyOne();
    701702        }
    702703    }
     
    707708uint64_t Connection::installIncomingSyncMessageCallback(std::function<void ()> callback)
    708709{
    709     std::lock_guard<std::mutex> lock(m_incomingSyncMessageCallbackMutex);
     710    std::lock_guard<Lock> lock(m_incomingSyncMessageCallbackMutex);
    710711
    711712    m_nextIncomingSyncMessageCallbackID++;
     
    721722void Connection::uninstallIncomingSyncMessageCallback(uint64_t callbackID)
    722723{
    723     std::lock_guard<std::mutex> lock(m_incomingSyncMessageCallbackMutex);
     724    std::lock_guard<Lock> lock(m_incomingSyncMessageCallbackMutex);
    724725    m_incomingSyncMessageCallbacks.remove(callbackID);
    725726}
     
    727728bool Connection::hasIncomingSyncMessage()
    728729{
    729     std::lock_guard<std::mutex> lock(m_incomingMessagesMutex);
     730    std::lock_guard<Lock> lock(m_incomingMessagesMutex);
    730731
    731732    for (auto& message : m_incomingMessages) {
     
    764765
    765766    {
    766         std::lock_guard<std::mutex> lock(m_waitForMessageMutex);
     767        std::lock_guard<Lock> lock(m_waitForMessageMutex);
    767768        if (m_waitingForMessage)
    768769            m_waitingForMessage->messageWaitingInterrupted = true;
    769770    }
    770     m_waitForMessageCondition.notify_all();
     771    m_waitForMessageCondition.notifyAll();
    771772
    772773    if (m_didCloseOnConnectionWorkQueueCallback)
     
    804805
    805806        {
    806             std::lock_guard<std::mutex> lock(m_outgoingMessagesMutex);
     807            std::lock_guard<Lock> lock(m_outgoingMessagesMutex);
    807808            if (m_outgoingMessages.isEmpty())
    808809                break;
     
    863864{
    864865    {
    865         std::lock_guard<std::mutex> lock(m_incomingMessagesMutex);
     866        std::lock_guard<Lock> lock(m_incomingMessagesMutex);
    866867        m_incomingMessages.append(WTF::move(incomingMessage));
    867868    }
     
    919920
    920921    {
    921         std::lock_guard<std::mutex> lock(m_incomingMessagesMutex);
     922        std::lock_guard<Lock> lock(m_incomingMessagesMutex);
    922923        if (m_incomingMessages.isEmpty())
    923924            return;
  • trunk/Source/WebKit2/Platform/IPC/Connection.h

    r188594 r188642  
    3535#include "ProcessType.h"
    3636#include <atomic>
    37 #include <condition_variable>
     37#include <wtf/Condition.h>
    3838#include <wtf/Deque.h>
    3939#include <wtf/Forward.h>
     
    260260
    261261    // Incoming messages.
    262     std::mutex m_incomingMessagesMutex;
     262    Lock m_incomingMessagesMutex;
    263263    Deque<std::unique_ptr<MessageDecoder>> m_incomingMessages;
    264264
    265265    // Outgoing messages.
    266     std::mutex m_outgoingMessagesMutex;
     266    Lock m_outgoingMessagesMutex;
    267267    Deque<std::unique_ptr<MessageEncoder>> m_outgoingMessages;
    268268   
    269     std::condition_variable m_waitForMessageCondition;
    270     std::mutex m_waitForMessageMutex;
     269    Condition m_waitForMessageCondition;
     270    Lock m_waitForMessageMutex;
    271271
    272272    WaitForMessageState* m_waitingForMessage;
     
    308308    SecondaryThreadPendingSyncReplyMap m_secondaryThreadPendingSyncReplyMap;
    309309
    310     std::mutex m_incomingSyncMessageCallbackMutex;
     310    Lock m_incomingSyncMessageCallbackMutex;
    311311    HashMap<uint64_t, std::function<void ()>> m_incomingSyncMessageCallbacks;
    312312    RefPtr<WorkQueue> m_incomingSyncMessageCallbackQueue;
  • trunk/Source/WebKit2/Shared/BlockingResponseMap.h

    r170774 r188642  
    2727#define BlockingResponseMap_h
    2828
    29 #include <condition_variable>
     29#include <wtf/Condition.h>
    3030#include <wtf/HashMap.h>
     31#include <wtf/Lock.h>
    3132#include <wtf/Noncopyable.h>
    3233
     
    4142    {
    4243        while (true) {
    43             std::unique_lock<std::mutex> lock(m_mutex);
     44            std::unique_lock<Lock> lock(m_mutex);
    4445
    4546            if (m_canceled)
     
    5758    void didReceiveResponse(uint64_t requestID, std::unique_ptr<T> response)
    5859    {
    59         std::lock_guard<std::mutex> lock(m_mutex);
     60        std::lock_guard<Lock> lock(m_mutex);
    6061        ASSERT(!m_responses.contains(requestID));
    6162
    6263        m_responses.set(requestID, WTF::move(response));
    6364
    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();
    6667    }
    6768
     
    7071        m_canceled = true;
    7172
    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();
    7475    }
    7576
    7677private:
    77     std::mutex m_mutex;
    78     std::condition_variable m_condition;
     78    Lock m_mutex;
     79    Condition m_condition;
    7980
    8081    HashMap<uint64_t, std::unique_ptr<T>> m_responses;
  • trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.cpp

    r179409 r188642  
    8080void PluginInfoCache::saveToFile()
    8181{
    82     std::lock_guard<std::mutex> lock(m_mutex);
     82    std::lock_guard<Lock> lock(m_mutex);
    8383
    8484    gsize dataLength;
     
    143143        // Save the cache file in an idle to make sure it happens in the main thread and
    144144        // 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);
    146146        if (m_saveToFileIdle.isScheduled())
    147147            return;
  • trunk/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoCache.h

    r185502 r188642  
    3131#include "PluginModuleInfo.h"
    3232#include <mutex>
     33#include <wtf/Lock.h>
    3334#include <wtf/NeverDestroyed.h>
    3435#include <wtf/glib/GMainLoopSource.h>
     
    5657    GMainLoopSource m_saveToFileIdle;
    5758    bool m_readOnlyMode;
    58     std::mutex m_mutex;
     59    Lock m_mutex;
    5960};
    6061
  • trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.h

    r180441 r188642  
    2828#import <WebCore/IntRectHash.h>
    2929#import <condition_variable>
     30#import <wtf/Condition.h>
     31#import <wtf/Lock.h>
    3032#import <wtf/RetainPtr.h>
    3133#import <wtf/Vector.h>
     
    5860
    5961    BOOL _isPrintingFromSecondaryThread;
    60     std::mutex _printingCallbackMutex;
    61     std::condition_variable _printingCallbackCondition;
     62    Lock _printingCallbackMutex;
     63    Condition _printingCallbackCondition;
    6264
    6365    NSTimer *_autodisplayResumeTimer;
  • trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.mm

    r187135 r188642  
    243243
    244244    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);
    250250
    251251    ASSERT([self _hasPageRects]);
     
    279279                view->_printedPagesData.append(data->bytes(), data->size());
    280280            view->_expectedPrintCallback = 0;
    281             view->_printingCallbackCondition.notify_one();
     281            view->_printingCallbackCondition.notifyOne();
    282282        }
    283283    });
     
    358358
    359359    WKPrintingView *view = static_cast<WKPrintingView *>(untypedContext);
    360     std::lock_guard<std::mutex> lock(view->_printingCallbackMutex);
     360    std::lock_guard<Lock> lock(view->_printingCallbackMutex);
    361361
    362362    // We may have received page rects while a message to call this function traveled from secondary thread to main one.
     
    396396    else if (!RunLoop::isMain()) {
    397397        ASSERT(![self _isPrintingPreview]);
    398         std::unique_lock<std::mutex> lock(_printingCallbackMutex);
     398        std::unique_lock<Lock> lock(_printingCallbackMutex);
    399399        callOnMainThread(prepareDataForPrintingOnSecondaryThread, self);
    400400        _printingCallbackCondition.wait(lock);
Note: See TracChangeset for help on using the changeset viewer.