summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/wtf/gtk/ThreadingGtk.cpp')
-rw-r--r--JavaScriptCore/wtf/gtk/ThreadingGtk.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp b/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp
index a6ec8f7..863ee81 100644
--- a/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp
+++ b/JavaScriptCore/wtf/gtk/ThreadingGtk.cpp
@@ -36,19 +36,20 @@
#include "HashMap.h"
#include "MainThread.h"
#include "RandomNumberSeed.h"
+#include <wtf/StdLibExtras.h>
#include <glib.h>
#include <limits.h>
namespace WTF {
-static Mutex* atomicallyInitializedStaticMutex;
+typedef HashMap<ThreadIdentifier, GThread*> ThreadMap;
-static ThreadIdentifier mainThreadIdentifier;
+static Mutex* atomicallyInitializedStaticMutex;
static Mutex& threadMapMutex()
{
- static Mutex mutex;
+ DEFINE_STATIC_LOCAL(Mutex, mutex, ());
return mutex;
}
@@ -62,8 +63,6 @@ void initializeThreading()
atomicallyInitializedStaticMutex = new Mutex;
threadMapMutex();
initializeRandomNumberGenerator();
- mainThreadIdentifier = currentThread();
- initializeMainThread();
}
}
@@ -78,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;
}
@@ -88,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;
@@ -168,9 +167,9 @@ ThreadIdentifier currentThread()
return establishIdentifierForThread(currentThread);
}
-bool isMainThread()
+void yield()
{
- return currentThread() == mainThreadIdentifier;
+ g_thread_yield();
}
Mutex::Mutex()