X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/ba379fdc102753d6be2c4d937058fe40257329fe..f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63:/wtf/qt/ThreadingQt.cpp diff --git a/wtf/qt/ThreadingQt.cpp b/wtf/qt/ThreadingQt.cpp index 1fdd2bb..dc04a68 100644 --- a/wtf/qt/ThreadingQt.cpp +++ b/wtf/qt/ThreadingQt.cpp @@ -29,6 +29,8 @@ #include "config.h" #include "Threading.h" +#if !ENABLE(SINGLE_THREADED) + #include "CurrentTime.h" #include "HashMap.h" #include "MainThread.h" @@ -64,6 +66,21 @@ void ThreadPrivate::run() m_returnValue = m_entryPoint(m_data); } +class ThreadMonitor : public QObject { + Q_OBJECT +public: + static ThreadMonitor * instance() + { + static ThreadMonitor *instance = new ThreadMonitor(); + return instance; + } + +public Q_SLOTS: + void threadFinished() + { + sender()->deleteLater(); + } +}; static Mutex* atomicallyInitializedStaticMutex; @@ -155,6 +172,9 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con LOG_ERROR("Failed to create thread at entry point %p with data %p", entryPoint, data); return 0; } + + QObject::connect(thread, SIGNAL(finished()), ThreadMonitor::instance(), SLOT(threadFinished())); + thread->start(); QThread* threadRef = static_cast(thread); @@ -162,7 +182,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con return establishIdentifierForThread(threadRef); } -void setThreadNameInternal(const char*) +void initializeCurrentThreadInternal(const char*) { } @@ -181,8 +201,10 @@ int waitForThreadCompletion(ThreadIdentifier threadID, void** result) return !res; } -void detachThread(ThreadIdentifier) +void detachThread(ThreadIdentifier threadID) { + ASSERT(threadID); + clearThreadForIdentifier(threadID); } ThreadIdentifier currentThread() @@ -267,3 +289,7 @@ void ThreadCondition::broadcast() } } // namespace WebCore + +#include "ThreadingQt.moc" + +#endif