Title: [161852] trunk/Source/WTF
Revision
161852
Author
[email protected]
Date
2014-01-12 18:36:50 -0800 (Sun, 12 Jan 2014)

Log Message

Remove AtomicallyInitializedStatic
https://bugs.webkit.org/show_bug.cgi?id=126864

Reviewed by Darin Adler.

* wtf/Threading.h:
* wtf/ThreadingPthreads.cpp:
(WTF::initializeThreading):
* wtf/ThreadingWin.cpp:
(WTF::initializeThreading):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (161851 => 161852)


--- trunk/Source/WTF/ChangeLog	2014-01-13 02:29:47 UTC (rev 161851)
+++ trunk/Source/WTF/ChangeLog	2014-01-13 02:36:50 UTC (rev 161852)
@@ -1,3 +1,16 @@
+2014-01-12  Anders Carlsson  <[email protected]>
+
+        Remove AtomicallyInitializedStatic
+        https://bugs.webkit.org/show_bug.cgi?id=126864
+
+        Reviewed by Darin Adler.
+
+        * wtf/Threading.h:
+        * wtf/ThreadingPthreads.cpp:
+        (WTF::initializeThreading):
+        * wtf/ThreadingWin.cpp:
+        (WTF::initializeThreading):
+
 2014-01-12  Darin Adler  <[email protected]>
 
         Add deprecatedCharacters as a synonym for characters and convert most call sites

Modified: trunk/Source/WTF/wtf/Threading.h (161851 => 161852)


--- trunk/Source/WTF/wtf/Threading.h	2014-01-13 02:29:47 UTC (rev 161851)
+++ trunk/Source/WTF/wtf/Threading.h	2014-01-13 02:36:50 UTC (rev 161852)
@@ -69,12 +69,6 @@
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/ThreadingPrimitives.h>
 
-// For portability, we do not use thread-safe statics natively supported by some compilers (e.g. gcc).
-#define AtomicallyInitializedStatic(T, name) \
-    WTF::lockAtomicallyInitializedStaticMutex(); \
-    static T name; \
-    WTF::unlockAtomicallyInitializedStaticMutex();
-
 namespace WTF {
 
 typedef uint32_t ThreadIdentifier;
@@ -100,9 +94,6 @@
 WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier);
 WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier);
 
-WTF_EXPORT_PRIVATE void lockAtomicallyInitializedStaticMutex();
-WTF_EXPORT_PRIVATE void unlockAtomicallyInitializedStaticMutex();
-
 } // namespace WTF
 
 using WTF::ThreadIdentifier;

Modified: trunk/Source/WTF/wtf/ThreadingPthreads.cpp (161851 => 161852)


--- trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2014-01-13 02:29:47 UTC (rev 161851)
+++ trunk/Source/WTF/wtf/ThreadingPthreads.cpp	2014-01-13 02:36:50 UTC (rev 161852)
@@ -98,8 +98,6 @@
 
 typedef HashMap<ThreadIdentifier, std::unique_ptr<PthreadState>> ThreadMap;
 
-static Mutex* atomicallyInitializedStaticMutex;
-
 void unsafeThreadWasDetached(ThreadIdentifier);
 void threadDidExit(ThreadIdentifier);
 void threadWasJoined(ThreadIdentifier);
@@ -112,14 +110,16 @@
 
 void initializeThreading()
 {
-    if (atomicallyInitializedStaticMutex)
+    static bool isInitialized;
+
+    if (isInitialized)
         return;
 
     WTF::double_conversion::initialize();
     // StringImpl::empty() does not construct its static string in a threadsafe fashion,
     // so ensure it has been initialized from here.
     StringImpl::empty();
-    atomicallyInitializedStaticMutex = new Mutex;
+
     threadMapMutex();
     initializeRandomNumberGenerator();
     ThreadIdentifierData::initializeOnce();
@@ -129,17 +129,6 @@
     initializeDates();
 }
 
-void lockAtomicallyInitializedStaticMutex()
-{
-    ASSERT(atomicallyInitializedStaticMutex);
-    atomicallyInitializedStaticMutex->lock();
-}
-
-void unlockAtomicallyInitializedStaticMutex()
-{
-    atomicallyInitializedStaticMutex->unlock();
-}
-
 static ThreadMap& threadMap()
 {
     DEFINE_STATIC_LOCAL(ThreadMap, map, ());

Modified: trunk/Source/WTF/wtf/ThreadingWin.cpp (161851 => 161852)


--- trunk/Source/WTF/wtf/ThreadingWin.cpp	2014-01-13 02:29:47 UTC (rev 161851)
+++ trunk/Source/WTF/wtf/ThreadingWin.cpp	2014-01-13 02:36:50 UTC (rev 161852)
@@ -148,19 +148,6 @@
 #endif
 }
 
-static Mutex* atomicallyInitializedStaticMutex;
-
-void lockAtomicallyInitializedStaticMutex()
-{
-    ASSERT(atomicallyInitializedStaticMutex);
-    atomicallyInitializedStaticMutex->lock();
-}
-
-void unlockAtomicallyInitializedStaticMutex()
-{
-    atomicallyInitializedStaticMutex->unlock();
-}
-
 static Mutex& threadMapMutex()
 {
     static Mutex mutex;
@@ -169,19 +156,22 @@
 
 void initializeThreading()
 {
-    if (atomicallyInitializedStaticMutex)
+    static bool isInitialized;
+    
+    if (isInitialized)
         return;
 
     WTF::double_conversion::initialize();
     // StringImpl::empty() does not construct its static string in a threadsafe fashion,
     // so ensure it has been initialized from here.
     StringImpl::empty();
-    atomicallyInitializedStaticMutex = new Mutex;
     threadMapMutex();
     initializeRandomNumberGenerator();
     wtfThreadData();
     s_dtoaP5Mutex = new Mutex;
     initializeDates();
+    
+    isInitialized = true;
 }
 
 static HashMap<DWORD, HANDLE>& threadMap()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to