Changeset 161849 in webkit


Ignore:
Timestamp:
Jan 12, 2014 6:23:52 PM (10 years ago)
Author:
andersca@apple.com
Message:

Remove the last remaining uses of AtomicallyInitializedStatic
https://bugs.webkit.org/show_bug.cgi?id=126863

Reviewed by Darin Adler.

Source/WebKit2:

  • Shared/mac/SecItemShim.cpp:

(WebKit::responseMap):

Source/WTF:

  • wtf/HashTable.cpp:

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

  • wtf/unicode/icu/CollatorICU.cpp:

(WTF::cachedCollatorMutex):
(WTF::Collator::createCollator):
(WTF::Collator::releaseCollator):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r161840 r161849  
     12014-01-12  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove the last remaining uses of AtomicallyInitializedStatic
     4        https://bugs.webkit.org/show_bug.cgi?id=126863
     5
     6        Reviewed by Darin Adler.
     7
     8        * wtf/HashTable.cpp:
     9        (WTF::hashTableStatsMutex):
     10        (WTF::HashTableStats::recordCollisionAtCount):
     11        (WTF::HashTableStats::dumpStats):
     12        * wtf/unicode/icu/CollatorICU.cpp:
     13        (WTF::cachedCollatorMutex):
     14        (WTF::Collator::createCollator):
     15        (WTF::Collator::releaseCollator):
     16
    1172014-01-12  Darin Adler  <darin@apple.com>
    218
  • trunk/Source/WTF/wtf/HashTable.cpp

    r135469 r161849  
    2020#include "config.h"
    2121#include "HashTable.h"
     22
    2223#include "DataLog.h"
     24#include <mutex>
    2325
    2426namespace WTF {
     
    3436int HashTableStats::numReinserts;
    3537
    36 static Mutex& hashTableStatsMutex()
     38static std::mutex& hashTableStatsMutex()
    3739{
    38     AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
    39     return mutex;
     40    static std::once_flag onceFlag;
     41    static std::mutex* mutex;
     42    std::call_once(onceFlag, []{
     43        mutex = std::make_unique<std::mutex>().release();
     44    });
     45
     46    return *mutex;
    4047}
    4148
    4249void HashTableStats::recordCollisionAtCount(int count)
    4350{
    44     MutexLocker lock(hashTableStatsMutex());
     51    std::lock_guard<std::mutex> lock(hashTableStatsMutex());
     52
    4553    if (count > maxCollisions)
    4654        maxCollisions = count;
     
    5159void HashTableStats::dumpStats()
    5260{
    53     MutexLocker lock(hashTableStatsMutex());
     61    std::lock_guard<std::mutex> lock(hashTableStatsMutex());
    5462
    5563    dataLogF("\nWTF::HashTable statistics\n\n");
  • trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp

    r156968 r161849  
    3232#if USE(ICU_UNICODE) && !UCONFIG_NO_COLLATION
    3333
     34#include <mutex>
    3435#include <wtf/Assertions.h>
    3536#include <wtf/StringExtras.h>
    36 #include <wtf/Threading.h>
    3737#include <unicode/ucol.h>
    3838#include <string.h>
     
    4646
    4747static UCollator* cachedCollator;
    48 static Mutex& cachedCollatorMutex()
     48
     49static std::mutex& cachedCollatorMutex()
    4950{
    50     AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
    51     return mutex;
     51    static std::once_flag onceFlag;
     52    static std::mutex* mutex;
     53    std::call_once(onceFlag, []{
     54        mutex = std::make_unique<std::mutex>().release();
     55    });
     56
     57    return *mutex;
    5258}
    5359
     
    105111
    106112    {
    107         Locker<Mutex> lock(cachedCollatorMutex());
     113        std::lock_guard<std::mutex> lock(cachedCollatorMutex());
    108114        if (cachedCollator) {
    109115            const char* cachedCollatorLocale = ucol_getLocaleByType(cachedCollator, ULOC_REQUESTED_LOCALE, &status);
     
    118124                && ((UCOL_LOWER_FIRST == cachedCollatorLowerFirst && m_lowerFirst) || (UCOL_UPPER_FIRST == cachedCollatorLowerFirst && !m_lowerFirst))) {
    119125                m_collator = cachedCollator;
    120                 cachedCollator = 0;
     126                cachedCollator = nullptr;
    121127                return;
    122128            }
     
    141147{
    142148    {
    143         Locker<Mutex> lock(cachedCollatorMutex());
     149        std::lock_guard<std::mutex> lock(cachedCollatorMutex());
    144150        if (cachedCollator)
    145151            ucol_close(cachedCollator);
    146152        cachedCollator = m_collator;
    147         m_collator  = 0;
     153        m_collator = nullptr;
    148154    }
    149155}
  • trunk/Source/WebKit2/ChangeLog

    r161836 r161849  
     12014-01-12  Anders Carlsson  <andersca@apple.com>
     2
     3        Remove the last remaining uses of AtomicallyInitializedStatic
     4        https://bugs.webkit.org/show_bug.cgi?id=126863
     5
     6        Reviewed by Darin Adler.
     7
     8        * Shared/mac/SecItemShim.cpp:
     9        (WebKit::responseMap):
     10
    1112014-01-12  Dan Bernstein  <mitz@apple.com>
    212
  • trunk/Source/WebKit2/Shared/mac/SecItemShim.cpp

    r161148 r161849  
    3838#include <Security/Security.h>
    3939#include <dlfcn.h>
     40#include <mutex>
    4041
    4142namespace WebKit {
     
    4344static BlockingResponseMap<SecItemResponseData>& responseMap()
    4445{
    45     AtomicallyInitializedStatic(BlockingResponseMap<SecItemResponseData>*, responseMap = new BlockingResponseMap<SecItemResponseData>);
     46    static std::once_flag onceFlag;
     47    static BlockingResponseMap<SecItemResponseData>* responseMap;
     48
     49    std::call_once(onceFlag, []{
     50        responseMap = std::make_unique<BlockingResponseMap<SecItemResponseData>>().release();
     51    });
     52
    4653    return *responseMap;
    4754}
Note: See TracChangeset for help on using the changeset viewer.