]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - wtf/gtk/ThreadingGtk.cpp
JavaScriptCore-903.tar.gz
[apple/javascriptcore.git] / wtf / gtk / ThreadingGtk.cpp
index 0c5cf0c98e3cb6cc77c001777d10390072e59171..863ee81d7ca3c3028d5e85de410366d52de45b89 100644 (file)
 #include "HashMap.h"
 #include "MainThread.h"
 #include "RandomNumberSeed.h"
+#include <wtf/StdLibExtras.h>
 
 #include <glib.h>
 #include <limits.h>
 
 namespace WTF {
 
+typedef HashMap<ThreadIdentifier, GThread*> ThreadMap;
+
 static Mutex* atomicallyInitializedStaticMutex;
 
 static Mutex& threadMapMutex()
 {
-    static Mutex mutex;
+    DEFINE_STATIC_LOCAL(Mutex, mutex, ());
     return mutex;
 }
 
@@ -74,9 +77,9 @@ void unlockAtomicallyInitializedStaticMutex()
     atomicallyInitializedStaticMutex->unlock();
 }
 
-static HashMap<ThreadIdentifier, GThread*>& threadMap()
+static ThreadMap& threadMap()
 {
-    static HashMap<ThreadIdentifier, GThread*> map;
+    DEFINE_STATIC_LOCAL(ThreadMap, map, ());
     return map;
 }
 
@@ -84,7 +87,7 @@ static ThreadIdentifier identifierByGthreadHandle(GThread*& thread)
 {
     MutexLocker locker(threadMapMutex());
 
-    HashMap<ThreadIdentifier, GThread*>::iterator i = threadMap().begin();
+    ThreadMap::iterator i = threadMap().begin();
     for (; i != threadMap().end(); ++i) {
         if (i->second == thread)
             return i->first;
@@ -164,6 +167,11 @@ ThreadIdentifier currentThread()
     return establishIdentifierForThread(currentThread);
 }
 
+void yield()
+{
+    g_thread_yield();
+}
+
 Mutex::Mutex()
     : m_mutex(g_mutex_new())
 {