#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;
}
atomicallyInitializedStaticMutex = new Mutex;
threadMapMutex();
initializeRandomNumberGenerator();
- mainThreadIdentifier = currentThread();
- initializeMainThread();
}
}
atomicallyInitializedStaticMutex->unlock();
}
-static HashMap<ThreadIdentifier, GThread*>& threadMap()
+static ThreadMap& threadMap()
{
- static HashMap<ThreadIdentifier, GThread*> map;
+ DEFINE_STATIC_LOCAL(ThreadMap, map, ());
return map;
}
{
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;
return threadID;
}
-void setThreadNameInternal(const char*)
+void initializeCurrentThreadInternal(const char*)
{
}
return establishIdentifierForThread(currentThread);
}
-bool isMainThread()
+void yield()
{
- return currentThread() == mainThreadIdentifier;
+ g_thread_yield();
}
Mutex::Mutex()