Title: [161849] trunk/Source
- Revision
- 161849
- Author
- [email protected]
- Date
- 2014-01-12 18:23:52 -0800 (Sun, 12 Jan 2014)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (161848 => 161849)
--- trunk/Source/WTF/ChangeLog 2014-01-13 02:07:18 UTC (rev 161848)
+++ trunk/Source/WTF/ChangeLog 2014-01-13 02:23:52 UTC (rev 161849)
@@ -1,3 +1,19 @@
+2014-01-12 Anders Carlsson <[email protected]>
+
+ Remove the last remaining uses of AtomicallyInitializedStatic
+ https://bugs.webkit.org/show_bug.cgi?id=126863
+
+ Reviewed by Darin Adler.
+
+ * wtf/HashTable.cpp:
+ (WTF::hashTableStatsMutex):
+ (WTF::HashTableStats::recordCollisionAtCount):
+ (WTF::HashTableStats::dumpStats):
+ * wtf/unicode/icu/CollatorICU.cpp:
+ (WTF::cachedCollatorMutex):
+ (WTF::Collator::createCollator):
+ (WTF::Collator::releaseCollator):
+
2014-01-12 Darin Adler <[email protected]>
Reduce use of String::characters
Modified: trunk/Source/WTF/wtf/HashTable.cpp (161848 => 161849)
--- trunk/Source/WTF/wtf/HashTable.cpp 2014-01-13 02:07:18 UTC (rev 161848)
+++ trunk/Source/WTF/wtf/HashTable.cpp 2014-01-13 02:23:52 UTC (rev 161849)
@@ -19,7 +19,9 @@
#include "config.h"
#include "HashTable.h"
+
#include "DataLog.h"
+#include <mutex>
namespace WTF {
@@ -33,15 +35,21 @@
int HashTableStats::numRemoves;
int HashTableStats::numReinserts;
-static Mutex& hashTableStatsMutex()
+static std::mutex& hashTableStatsMutex()
{
- AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
- return mutex;
+ static std::once_flag onceFlag;
+ static std::mutex* mutex;
+ std::call_once(onceFlag, []{
+ mutex = std::make_unique<std::mutex>().release();
+ });
+
+ return *mutex;
}
void HashTableStats::recordCollisionAtCount(int count)
{
- MutexLocker lock(hashTableStatsMutex());
+ std::lock_guard<std::mutex> lock(hashTableStatsMutex());
+
if (count > maxCollisions)
maxCollisions = count;
numCollisions++;
@@ -50,7 +58,7 @@
void HashTableStats::dumpStats()
{
- MutexLocker lock(hashTableStatsMutex());
+ std::lock_guard<std::mutex> lock(hashTableStatsMutex());
dataLogF("\nWTF::HashTable statistics\n\n");
dataLogF("%d accesses\n", numAccesses);
Modified: trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp (161848 => 161849)
--- trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp 2014-01-13 02:07:18 UTC (rev 161848)
+++ trunk/Source/WTF/wtf/unicode/icu/CollatorICU.cpp 2014-01-13 02:23:52 UTC (rev 161849)
@@ -31,9 +31,9 @@
#if USE(ICU_UNICODE) && !UCONFIG_NO_COLLATION
+#include <mutex>
#include <wtf/Assertions.h>
#include <wtf/StringExtras.h>
-#include <wtf/Threading.h>
#include <unicode/ucol.h>
#include <string.h>
@@ -45,10 +45,16 @@
namespace WTF {
static UCollator* cachedCollator;
-static Mutex& cachedCollatorMutex()
+
+static std::mutex& cachedCollatorMutex()
{
- AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
- return mutex;
+ static std::once_flag onceFlag;
+ static std::mutex* mutex;
+ std::call_once(onceFlag, []{
+ mutex = std::make_unique<std::mutex>().release();
+ });
+
+ return *mutex;
}
Collator::Collator(const char* locale)
@@ -104,7 +110,7 @@
UErrorCode status = U_ZERO_ERROR;
{
- Locker<Mutex> lock(cachedCollatorMutex());
+ std::lock_guard<std::mutex> lock(cachedCollatorMutex());
if (cachedCollator) {
const char* cachedCollatorLocale = ucol_getLocaleByType(cachedCollator, ULOC_REQUESTED_LOCALE, &status);
ASSERT(U_SUCCESS(status));
@@ -117,7 +123,7 @@
if (m_locale && 0 == strcmp(cachedCollatorLocale, m_locale)
&& ((UCOL_LOWER_FIRST == cachedCollatorLowerFirst && m_lowerFirst) || (UCOL_UPPER_FIRST == cachedCollatorLowerFirst && !m_lowerFirst))) {
m_collator = cachedCollator;
- cachedCollator = 0;
+ cachedCollator = nullptr;
return;
}
}
@@ -140,11 +146,11 @@
void Collator::releaseCollator()
{
{
- Locker<Mutex> lock(cachedCollatorMutex());
+ std::lock_guard<std::mutex> lock(cachedCollatorMutex());
if (cachedCollator)
ucol_close(cachedCollator);
cachedCollator = m_collator;
- m_collator = 0;
+ m_collator = nullptr;
}
}
Modified: trunk/Source/WebKit2/ChangeLog (161848 => 161849)
--- trunk/Source/WebKit2/ChangeLog 2014-01-13 02:07:18 UTC (rev 161848)
+++ trunk/Source/WebKit2/ChangeLog 2014-01-13 02:23:52 UTC (rev 161849)
@@ -1,3 +1,13 @@
+2014-01-12 Anders Carlsson <[email protected]>
+
+ Remove the last remaining uses of AtomicallyInitializedStatic
+ https://bugs.webkit.org/show_bug.cgi?id=126863
+
+ Reviewed by Darin Adler.
+
+ * Shared/mac/SecItemShim.cpp:
+ (WebKit::responseMap):
+
2014-01-12 Dan Bernstein <[email protected]>
Added a reference to WebContentService/Info-OSX.plist to the project.
Modified: trunk/Source/WebKit2/Shared/mac/SecItemShim.cpp (161848 => 161849)
--- trunk/Source/WebKit2/Shared/mac/SecItemShim.cpp 2014-01-13 02:07:18 UTC (rev 161848)
+++ trunk/Source/WebKit2/Shared/mac/SecItemShim.cpp 2014-01-13 02:23:52 UTC (rev 161849)
@@ -37,12 +37,19 @@
#include "SecItemShimProxyMessages.h"
#include <Security/Security.h>
#include <dlfcn.h>
+#include <mutex>
namespace WebKit {
static BlockingResponseMap<SecItemResponseData>& responseMap()
{
- AtomicallyInitializedStatic(BlockingResponseMap<SecItemResponseData>*, responseMap = new BlockingResponseMap<SecItemResponseData>);
+ static std::once_flag onceFlag;
+ static BlockingResponseMap<SecItemResponseData>* responseMap;
+
+ std::call_once(onceFlag, []{
+ responseMap = std::make_unique<BlockingResponseMap<SecItemResponseData>>().release();
+ });
+
return *responseMap;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes