2008-02-23 Alexey Proskuryakov <ap@webkit.org>
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Feb 2008 19:50:04 +0000 (19:50 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Feb 2008 19:50:04 +0000 (19:50 +0000)
        Reviewed by Darin.

        Move basic threading support from WebCore to WTF.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@30522 268f45cc-cd09-0410-ab3c-d52691b4dbfc

55 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/GNUmakefile.am
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/JavaScriptCore.pri
JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/JavaScriptCoreSources.bkl
JavaScriptCore/wtf/Locker.h [moved from WebCore/platform/Locker.h with 98% similarity]
JavaScriptCore/wtf/MessageQueue.h [moved from WebCore/platform/MessageQueue.h with 92% similarity]
JavaScriptCore/wtf/Threading.h [moved from WebCore/platform/Threading.h with 95% similarity]
JavaScriptCore/wtf/ThreadingGtk.cpp [moved from WebCore/platform/gtk/ThreadingGtk.cpp with 85% similarity]
JavaScriptCore/wtf/ThreadingNone.cpp [moved from WebCore/platform/ThreadingNone.cpp with 100% similarity]
JavaScriptCore/wtf/ThreadingPthreads.cpp [moved from WebCore/platform/pthreads/ThreadingPthreads.cpp with 97% similarity]
JavaScriptCore/wtf/ThreadingWin.cpp [moved from WebCore/platform/win/MutexWin.cpp with 55% similarity]
WebCore/ChangeLog
WebCore/ForwardingHeaders/wtf/Locker.h [new file with mode: 0644]
WebCore/ForwardingHeaders/wtf/MessageQueue.h [new file with mode: 0644]
WebCore/ForwardingHeaders/wtf/Threading.h [new file with mode: 0644]
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/WebCoreSources.bkl
WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp
WebCore/dom/XMLTokenizer.cpp
WebCore/loader/icon/IconDatabase.cpp
WebCore/loader/icon/IconDatabase.h
WebCore/platform/MainThread.h [new file with mode: 0644]
WebCore/platform/SecurityOrigin.h
WebCore/platform/gtk/MainThreadGtk.cpp [new file with mode: 0644]
WebCore/platform/mac/MainThreadMac.mm [moved from WebCore/platform/mac/Threading.mm with 99% similarity]
WebCore/platform/qt/MainThreadQt.cpp [moved from WebCore/platform/qt/ThreadingQt.cpp with 98% similarity]
WebCore/platform/sql/SQLValue.h
WebCore/platform/sql/SQLiteAuthorizer.h
WebCore/platform/sql/SQLiteDatabase.h
WebCore/platform/win/MainThreadWin.cpp [moved from WebCore/platform/win/ThreadingWin.cpp with 63% similarity]
WebCore/platform/wx/MainThreadWx.cpp [moved from WebCore/platform/wx/ThreadingWx.cpp with 98% similarity]
WebCore/storage/Database.cpp
WebCore/storage/Database.h
WebCore/storage/DatabaseTask.h
WebCore/storage/DatabaseThread.h
WebCore/storage/DatabaseTracker.cpp
WebCore/storage/OriginQuotaManager.h
WebCore/storage/SQLError.h
WebCore/storage/SQLResultSet.h
WebCore/storage/SQLStatement.h
WebCore/storage/SQLStatementCallback.h
WebCore/storage/SQLStatementErrorCallback.h
WebCore/storage/SQLTransaction.h
WebCore/storage/SQLTransactionCallback.h
WebCore/storage/SQLTransactionErrorCallback.h
WebCore/webcore-wx.bkl
WebKit/mac/ChangeLog
WebKit/mac/ForwardingHeaders/wtf/Locker.h [new file with mode: 0644]
WebKit/mac/ForwardingHeaders/wtf/Threading.h [new file with mode: 0644]

index 27b7a82e587f0d9613cde9304d941c0fde206b90..1632292c38082143f30fd7b1cd2fff2a238c74e7 100644 (file)
@@ -1,3 +1,34 @@
+2008-02-23  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        Move basic threading support from WebCore to WTF.
+
+        Added mutex protection to MessageQueue::killed() for paranoia sake.
+
+        * GNUmakefile.am:
+        * JavaScriptCore.exp:
+        * JavaScriptCore.pri:
+        * JavaScriptCore.vcproj/WTF/WTF.vcproj:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * JavaScriptCoreSources.bkl:
+        * wtf/Locker.h: Copied from WebCore/platform/Locker.h.
+        * wtf/MessageQueue.h: Copied from WebCore/platform/MessageQueue.h.
+        (WTF::::killed):
+        * wtf/Threading.h: Copied from WebCore/platform/Threading.h.
+        * wtf/ThreadingGtk.cpp: Copied from WebCore/platform/gtk/ThreadingGtk.cpp.
+        (WebCore::createThread):
+        * wtf/ThreadingNone.cpp: Copied from WebCore/platform/ThreadingNone.cpp.
+        * wtf/ThreadingPthreads.cpp: Copied from WebCore/platform/pthreads/ThreadingPthreads.cpp.
+        (WTF::createThread):
+        * wtf/ThreadingWin.cpp: Copied from WebCore/platform/win/ThreadingWin.cpp.
+        (WTF::createThread):
+        (WTF::Mutex::Mutex):
+        (WTF::Mutex::~Mutex):
+        (WTF::Mutex::lock):
+        (WTF::Mutex::tryLock):
+        (WTF::Mutex::unlock):
+
 2008-02-22  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by Sam Weinig.
index b1f0274694b4d7c6b091383796c7c8f780f18b24..7e11e843b766eae68cbec4fa7b3bae3e75ad8023 100644 (file)
@@ -60,6 +60,7 @@ javascriptcore_sources += \
        JavaScriptCore/pcre/pcre_xclass.cpp \
        JavaScriptCore/wtf/Assertions.cpp \
        JavaScriptCore/wtf/HashTable.cpp \
+       JavaScriptCore/wtf/ThreadingGtk.cpp \
        JavaScriptCore/wtf/unicode/UTF8.cpp
 
 # Debug build
index 3e43074f0d930098cd371c660854b0ca3b554fec..ab313c78c6bd942499e2dfaa653cfc6b947fee29 100644 (file)
@@ -298,3 +298,17 @@ _jscore_collector_introspection
 _jscore_fastmalloc_introspection
 _kJSClassDefinitionEmpty
 _kjs_strtod
+__ZN3WTF5MutexC1Ev
+__ZN3WTF5MutexD1Ev
+__ZN3WTF15ThreadCondition4waitERNS_5MutexE
+__ZN3WTF5Mutex7tryLockEv
+__ZN3WTF12detachThreadEj
+__ZN3WTF13currentThreadEv
+__ZN3WTF5Mutex4lockEv
+__ZN3WTF23waitForThreadCompletionEjPPv
+__ZN3WTF15ThreadConditionC1Ev
+__ZN3WTF15ThreadConditionD1Ev
+__ZN3WTF5Mutex6unlockEv
+__ZN3WTF12createThreadEPFPvS0_ES0_
+__ZN3WTF15ThreadCondition9broadcastEv
+__ZN3WTF15ThreadCondition6signalEv
index d7cbc6a3d99b01a1f680534f60a348b79892f271..d5a8d7ba20ecabacd555c2830881cf8937ae12dd 100644 (file)
@@ -113,10 +113,19 @@ SOURCES += \
 }
 
 qt-port:SOURCES += \
+    wtf/ThreadingPthreads.cpp \
     bindings/qt/qt_class.cpp \
     bindings/qt/qt_instance.cpp \
     bindings/qt/qt_runtime.cpp
 
+gtk-port:SOURCES += \
+    wtf/ThreadingGtk.cpp
+}
+
+!gtk-port:SOURCES += \
+    wtf/ThreadingNone.cpp
+}
+
 !CONFIG(QTDIR_build) {
     defineTest(addExtraCompiler) {
         QMAKE_EXTRA_COMPILERS += $$1
index befffdd2f9657365dbb11a191202c1147480eca6..19609751448455e922a34beeaf3153594bfc5da3 100644 (file)
                        RelativePath="..\..\wtf\ListRefPtr.h"\r
                        >\r
                </File>\r
+               <File\r
+                       RelativePath="..\..\wtf\Locker.h"\r
+                       >\r
+               </File>\r
                <File\r
                        RelativePath="..\..\wtf\MathExtras.h"\r
                        >\r
                </File>\r
+               <File\r
+                       RelativePath="..\..\wtf\MessageQueue.h"\r
+                       >\r
+               </File>\r
                <File\r
                        RelativePath="..\..\wtf\Noncopyable.h"\r
                        >\r
                        RelativePath="..\..\wtf\TCSystemAlloc.h"\r
                        >\r
                </File>\r
+               <File\r
+                       RelativePath="..\..\wtf\Threading.h"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\..\wtf\ThreadingWin.cpp"\r
+                       >\r
+               </File>\r
                <File\r
                        RelativePath="..\..\wtf\unicode\Unicode.h"\r
                        >\r
index c53f2367278f4fea81550471ef73b252b80a8983..b1981d0edd299f341cc7575ca4005a17f36851ed 100644 (file)
                E11D51760B2E798D0056C188 /* StringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = E11D51750B2E798D0056C188 /* StringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E195679609E7CF1200B89D13 /* UnicodeIcu.h in Headers */ = {isa = PBXBuildFile; fileRef = E195678F09E7CF1200B89D13 /* UnicodeIcu.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E195679809E7CF1200B89D13 /* Unicode.h in Headers */ = {isa = PBXBuildFile; fileRef = E195679409E7CF1200B89D13 /* Unicode.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E1EE79230D6C95CD00FEA3BA /* Threading.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE79220D6C95CD00FEA3BA /* Threading.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E1EE79280D6C964500FEA3BA /* Locker.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE79270D6C964500FEA3BA /* Locker.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E1EE793D0D6C9B9200FEA3BA /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EE793C0D6C9B9200FEA3BA /* ThreadingPthreads.cpp */; };
+               E1EE798C0D6CA53D00FEA3BA /* MessageQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE798B0D6CA53D00FEA3BA /* MessageQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E1EF79AA0CE97BA60088D500 /* UTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EF79A80CE97BA60088D500 /* UTF8.cpp */; };
                E1EF79AB0CE97BA60088D500 /* UTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EF79A90CE97BA60088D500 /* UTF8.h */; };
 /* End PBXBuildFile section */
                E11D51750B2E798D0056C188 /* StringExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringExtras.h; sourceTree = "<group>"; };
                E195678F09E7CF1200B89D13 /* UnicodeIcu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnicodeIcu.h; sourceTree = "<group>"; };
                E195679409E7CF1200B89D13 /* Unicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Unicode.h; sourceTree = "<group>"; };
+               E1EE79220D6C95CD00FEA3BA /* Threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Threading.h; sourceTree = "<group>"; };
+               E1EE79270D6C964500FEA3BA /* Locker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Locker.h; sourceTree = "<group>"; };
+               E1EE793C0D6C9B9200FEA3BA /* ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadingPthreads.cpp; sourceTree = "<group>"; };
+               E1EE798B0D6CA53D00FEA3BA /* MessageQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageQueue.h; sourceTree = "<group>"; };
                E1EF79A80CE97BA60088D500 /* UTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UTF8.cpp; sourceTree = "<group>"; };
                E1EF79A90CE97BA60088D500 /* UTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTF8.h; sourceTree = "<group>"; };
                F5BB2BC5030F772101FCFE1D /* completion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = completion.h; sourceTree = "<group>"; tabWidth = 8; };
                                65DFC92F08EA173A00F7300B /* HashTraits.h */,
                                657EB7450B708F540063461B /* ListHashSet.h */,
                                148A1626095D16BB00666D0D /* ListRefPtr.h */,
+                               E1EE79270D6C964500FEA3BA /* Locker.h */,
                                5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */,
                                BCF6553B0A2048DE0038A194 /* MathExtras.h */,
+                               E1EE798B0D6CA53D00FEA3BA /* MessageQueue.h */,
                                9303F5690991190000AD71B8 /* Noncopyable.h */,
                                9303F5A409911A5800AD71B8 /* OwnArrayPtr.h */,
                                9303F567099118FA00AD71B8 /* OwnPtr.h */,
                                6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */,
                                6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */,
                                6541BD7108E80A17002CBEE7 /* TCSystemAlloc.h */,
+                               E1EE79220D6C95CD00FEA3BA /* Threading.h */,
+                               E1EE793C0D6C9B9200FEA3BA /* ThreadingPthreads.cpp */,
                                E195678D09E7CF1200B89D13 /* unicode */,
                                935AF46B09E9D9DB00ACD1D8 /* UnusedParam.h */,
                                6592C316098B7DE10003D4F6 /* Vector.h */,
                                65F340940CD6C1C000C0CA8B /* LocalStorage.h in Headers */,
                                5DBD18B00C5401A700C15EAE /* MallocZoneSupport.h in Headers */,
                                BCF655590A2049710038A194 /* MathExtras.h in Headers */,
+                               E1EE798C0D6CA53D00FEA3BA /* MessageQueue.h in Headers */,
                                932F5B840822A1C700736975 /* NP_jsobject.h in Headers */,
                                9303F56A0991190000AD71B8 /* Noncopyable.h in Headers */,
                                9303F5A509911A5800AD71B8 /* OwnArrayPtr.h in Headers */,
                                6541BD7208E80A17002CBEE7 /* TCPageMap.h in Headers */,
                                6541BD7308E80A17002CBEE7 /* TCSpinLock.h in Headers */,
                                6541BD7508E80A17002CBEE7 /* TCSystemAlloc.h in Headers */,
+                               E1EE79230D6C95CD00FEA3BA /* Threading.h in Headers */,
                                E1EF79AB0CE97BA60088D500 /* UTF8.h in Headers */,
                                E195679809E7CF1200B89D13 /* Unicode.h in Headers */,
                                E195679609E7CF1200B89D13 /* UnicodeIcu.h in Headers */,
                                93E26BFE08B151D400F85226 /* ucpinternal.h in Headers */,
                                932F5B5C0822A1C700736975 /* ustring.h in Headers */,
                                14ABB36F099C076400E2A24F /* value.h in Headers */,
+                               E1EE79280D6C964500FEA3BA /* Locker.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                932F5BBD0822A1C700736975 /* runtime_method.cpp in Sources */,
                                932F5BBA0822A1C700736975 /* runtime_object.cpp in Sources */,
                                932F5BC50822A1C700736975 /* runtime_root.cpp in Sources */,
+                               E1EE793D0D6C9B9200FEA3BA /* ThreadingPthreads.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 2a1312b9097e1c6c5720d9766e4b788549e95c75..17c8d14a402ad90dbc2da507a5f3206a38d1d7b3 100644 (file)
@@ -113,6 +113,7 @@ Source files for JSCore.
         wtf/FastMalloc.cpp
         wtf/HashTable.cpp
         wtf/TCSystemAlloc.cpp
+        wtf/ThreadingNone.cpp
         wtf/unicode/UTF8.cpp
     </set>
 
similarity index 98%
rename from WebCore/platform/Locker.h
rename to JavaScriptCore/wtf/Locker.h
index 7217bf1c898cae4de5038c459ebe6acdd55dbedd..9feec1f3f7e79aa11349b64ed4f43316716878a2 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <wtf/Noncopyable.h>
 
-namespace WebCore {
+namespace WTF {
 
 template <typename T> class Locker : Noncopyable {
 public:
@@ -42,4 +42,6 @@ private:
 
 }
 
+using WTF::Locker;
+
 #endif
similarity index 92%
rename from WebCore/platform/MessageQueue.h
rename to JavaScriptCore/wtf/MessageQueue.h
index dd35449303401726ead99ad9ba5a249c433e6123..c13b590ff2cbc89485de3d171513c18cf36c646a 100644 (file)
 #ifndef MessageQueue_h
 #define MessageQueue_h
 
-#include "Threading.h"
 #include <wtf/Assertions.h>
 #include <wtf/Deque.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/Threading.h>
 
-namespace WebCore {
+namespace WTF {
 
     template<typename DataType>
     class MessageQueue : Noncopyable {
@@ -46,10 +46,10 @@ namespace WebCore {
         bool waitForMessage(DataType&);
         bool tryGetMessage(DataType&);
         void kill();
-        bool killed() const { return m_killed; }
+        bool killed() const;
 
     private:
-        Mutex m_mutex;
+        mutable Mutex m_mutex;
         ThreadCondition m_condition;
         Deque<DataType> m_queue;
         bool m_killed;
@@ -110,6 +110,15 @@ namespace WebCore {
         m_killed = true;
         m_condition.broadcast();
     }
+
+    template<typename DataType>
+    inline bool MessageQueue<DataType>::killed() const
+    {
+        MutexLocker lock(m_mutex);
+        return m_killed;
+    }
 }
 
+using WTF::MessageQueue;
+
 #endif // MessageQueue_h
similarity index 95%
rename from WebCore/platform/Threading.h
rename to JavaScriptCore/wtf/Threading.h
index 759351e5de9127a154302a1f73e16ac06acf8fab..1cb52729a408bb8432dcdb2590ce4ec6d628ac14 100644 (file)
@@ -59,9 +59,8 @@
 #ifndef Threading_h
 #define Threading_h
 
-#include "Locker.h"
-
 #include <wtf/Assertions.h>
+#include <wtf/Locker.h>
 #include <wtf/Noncopyable.h>
 
 #if PLATFORM(WIN_OS)
@@ -92,7 +91,7 @@ class QWaitCondition;
 
 #include <stdint.h>
 
-namespace WebCore {
+namespace WTF {
 
 typedef uint32_t ThreadIdentifier;
 typedef void* (*ThreadFunction)(void* argument);
@@ -231,18 +230,26 @@ private:
 #endif
 };
 
-typedef void MainThreadFunction(void*);
-
-void callOnMainThread(MainThreadFunction*, void* context);
-
 void initializeThreading();
 
-#if !PLATFORM(WIN) && !PLATFORM(GTK)
+#if !PLATFORM(GTK)
 inline void initializeThreading()
 {
 }
 #endif
 
-} // namespace WebCore
+} // namespace WTF
+
+using WTF::Mutex;
+using WTF::MutexLocker;
+using WTF::ThreadCondition;
+using WTF::ThreadIdentifier;
+using WTF::ThreadSafeShared;
+
+using WTF::createThread;
+using WTF::currentThread;
+using WTF::detachThread;
+using WTF::initializeThreading;
+using WTF::waitForThreadCompletion;
 
 #endif // Threading_h
similarity index 85%
rename from WebCore/platform/gtk/ThreadingGtk.cpp
rename to JavaScriptCore/wtf/ThreadingGtk.cpp
index 5ce6ba2ea7a80865a6824d2a7eef2d221944714b..43c60c14bcf1fbc03bcf39eaa17067c488db8977 100644 (file)
 #include "Threading.h"
 
 #include "HashMap.h"
-#include "Logging.h"
 
 #include <glib.h>
 
 namespace WebCore {
 
-struct FunctionWithContext {
-    MainThreadFunction* function;
-    void* context;
-};
-
-static gboolean callFunctionOnMainThread(gpointer data)
-{
-    FunctionWithContext* functionWithContext = static_cast<FunctionWithContext*>(data);
-    functionWithContext->function(functionWithContext->context);
-    delete functionWithContext;
-    return FALSE;
-}
-
-void callOnMainThread(MainThreadFunction* function, void* context)
-{
-    ASSERT(function);
-    FunctionWithContext* functionWithContext = new FunctionWithContext;
-    functionWithContext->function = function;
-    functionWithContext->context = context;
-    g_timeout_add(0, callFunctionOnMainThread, functionWithContext);
-}
-
 void initializeThreading()
 {
     if (!g_thread_supported())
@@ -127,7 +104,6 @@ ThreadIdentifier createThread(ThreadFunction entryPoint, void* data)
     }
 
     ThreadIdentifier threadID = establishIdentifierForThread(thread);
-    LOG(Threading, "Created thread with thread id %u", threadID);
     return threadID;
 }
 
similarity index 97%
rename from WebCore/platform/pthreads/ThreadingPthreads.cpp
rename to JavaScriptCore/wtf/ThreadingPthreads.cpp
index c12fd924f2e51411420727a7df540c69f1478c32..2fea5ba7df3074c032283236f446ccf6b76111ea 100644 (file)
 #include "config.h"
 #include "Threading.h"
 
-#include "Logging.h"
 #include <wtf/HashMap.h>
 
 #include <errno.h>
 
-namespace WebCore {
+namespace WTF {
 
 static Mutex& threadMapMutex()
 {
@@ -97,7 +96,6 @@ ThreadIdentifier createThread(ThreadFunction entryPoint, void* data)
     }
 
     ThreadIdentifier threadID = establishIdentifierForPthreadHandle(threadHandle);
-    LOG(Threading, "Created thread with thread id %u", threadID);
     return threadID;
 }
 
@@ -197,4 +195,4 @@ void ThreadCondition::broadcast()
         ASSERT(false);
 }
     
-} // namespace WebCore
+} // namespace WTF
similarity index 55%
rename from WebCore/platform/win/MutexWin.cpp
rename to JavaScriptCore/wtf/ThreadingWin.cpp
index 41d7fe45cb911fe425051a1a975cc5bf6085b375..46dff939cf8312b3118983ae259ad837ce4fa65b 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Brent Fulgham
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 #include "config.h"
 #include "Threading.h"
 
-namespace WebCore {
+#include <windows.h>
+#include <wtf/HashMap.h>
+
+namespace WTF {
+
+static Mutex& threadMapMutex()
+{
+    static Mutex mutex;
+    return mutex;
+}
+
+static HashMap<DWORD, HANDLE>& threadMap()
+{
+    static HashMap<DWORD, HANDLE> map;
+    return map;
+}
+
+static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle)
+{
+    MutexLocker locker(threadMapMutex());
+    threadMap().add(threadID, threadHandle);
+}
+
+static HANDLE threadHandleForIdentifier(ThreadIdentifier id)
+{
+    MutexLocker locker(threadMapMutex());
+    return threadMap().get(id);
+}
+
+static void clearThreadHandleForIdentifier(ThreadIdentifier id)
+{
+    MutexLocker locker(threadMapMutex());
+    ASSERT(threadMap().contains(id));
+    threadMap().remove(id);
+}
+
+ThreadIdentifier createThread(ThreadFunction entryPoint, void* data)
+{
+    DWORD threadIdentifier = 0;
+    ThreadIdentifier threadID = 0;
+    HANDLE hEvent = ::CreateEvent(0, FALSE, FALSE, 0);
+    HANDLE threadHandle = ::CreateThread(0, 0, (LPTHREAD_START_ROUTINE)entryPoint, data, 0, &threadIdentifier);
+    if (!threadHandle) {
+        LOG_ERROR("Failed to create thread at entry point %p with data %p", entryPoint, data);
+        return 0;
+    }
+
+    threadID = static_cast<ThreadIdentifier>(threadIdentifier);
+    storeThreadHandleByIdentifier(threadIdentifier, threadHandle);
+
+    return threadID;
+}
+
+int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
+{
+    ASSERT(threadID);
+    
+    HANDLE threadHandle = threadHandleForIdentifier(threadID);
+    if (!threadHandle)
+        LOG_ERROR("ThreadIdentifier %u did not correspond to an active thread when trying to quit", threadID);
+    DWORD joinResult = ::WaitForSingleObject(threadHandle, INFINITE);
+    if (joinResult == WAIT_FAILED)
+        LOG_ERROR("ThreadIdentifier %u was found to be deadlocked trying to quit", threadID);
+
+    ::CloseHandle(threadHandle);
+    clearThreadHandleForIdentifier(threadID);
+
+    return joinResult;
+}
+
+void detachThread(ThreadIdentifier threadID)
+{
+    ASSERT(threadID);
+    
+    HANDLE threadHandle = threadHandleForIdentifier(threadID);
+    if (threadHandle)
+        ::CloseHandle(threadHandle);
+    clearThreadHandleForIdentifier(threadID);
+}
+
+ThreadIdentifier currentThread()
+{
+    return static_cast<ThreadIdentifier>(::GetCurrentThreadId());
+}
 
 Mutex::Mutex()
 {
@@ -80,4 +164,4 @@ void Mutex::unlock()
     ::LeaveCriticalSection(&m_mutex.m_internalMutex);
 }
 
-} // namespace WebCore
+} // namespace WTF
index af81f67393bd6a648792c8c2cc0282714c7fb4d7..561ffeaee4262b0b4a25988634017088954d950b 100644 (file)
@@ -1,3 +1,65 @@
+2008-02-23  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        Move basic threading support from WebCore to WTF.
+
+        One call that remains in WebCore is callOnMainThread(), and it has its own header now.
+
+        * ForwardingHeaders/wtf/Locker.h: Added.
+        * ForwardingHeaders/wtf/MessageQueue.h: Added.
+        * ForwardingHeaders/wtf/Threading.h: Added.
+        * GNUmakefile.am:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * WebCoreSources.bkl:
+        * bindings/js/JSCustomSQLTransactionCallback.cpp:
+        * dom/XMLTokenizer.cpp:
+        * loader/icon/IconDatabase.cpp:
+        (WebCore::iconDatabase):
+        * loader/icon/IconDatabase.h:
+        * platform/Locker.h: Removed.
+        * platform/MainThread.h: Copied from WebCore/platform/Threading.h.
+        (WebCore::initializeThreadingAndMainThread):
+        * platform/MessageQueue.h: Removed.
+        * platform/SecurityOrigin.h:
+        * platform/Threading.h: Removed.
+        * platform/ThreadingNone.cpp: Removed.
+        * platform/gtk/MainThreadGtk.cpp: Copied from WebCore/platform/gtk/ThreadingGtk.cpp.
+        * platform/gtk/ThreadingGtk.cpp: Removed.
+        * platform/mac/MainThreadMac.mm: Copied from WebCore/platform/mac/Threading.mm.
+        * platform/mac/Threading.mm: Removed.
+        * platform/pthreads: Removed.
+        * platform/pthreads/ThreadingPthreads.cpp: Removed.
+        * platform/qt/MainThreadQt.cpp: Copied from WebCore/platform/qt/ThreadingQt.cpp.
+        * platform/qt/ThreadingQt.cpp: Removed.
+        * platform/sql/SQLValue.h:
+        * platform/sql/SQLiteAuthorizer.h:
+        * platform/sql/SQLiteDatabase.h:
+        * platform/win/MainThreadWin.cpp: Copied from WebCore/platform/win/ThreadingWin.cpp.
+        (WebCore::initializeThreadingAndMainThread):
+        * platform/win/MutexWin.cpp: Removed.
+        * platform/win/ThreadingWin.cpp: Removed.
+        * platform/wx/MainThreadWx.cpp: Copied from WebCore/platform/wx/ThreadingWx.cpp.
+        * platform/wx/ThreadingWx.cpp: Removed.
+        * storage/Database.cpp:
+        (WebCore::Database::Database):
+        * storage/Database.h:
+        * storage/DatabaseTask.h:
+        * storage/DatabaseThread.h:
+        * storage/DatabaseTracker.cpp:
+        * storage/OriginQuotaManager.h:
+        * storage/SQLError.h:
+        * storage/SQLResultSet.h:
+        * storage/SQLStatement.h:
+        * storage/SQLStatementCallback.h:
+        * storage/SQLStatementErrorCallback.h:
+        * storage/SQLTransaction.h:
+        * storage/SQLTransactionCallback.h:
+        * storage/SQLTransactionErrorCallback.h:
+        * webcore-wx.bkl:
+
 2008-02-23  David Kilzer  <ddkilzer@apple.com>
 
         Please clarify licensing for some files
diff --git a/WebCore/ForwardingHeaders/wtf/Locker.h b/WebCore/ForwardingHeaders/wtf/Locker.h
new file mode 100644 (file)
index 0000000..75b0acd
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/Locker.h>
diff --git a/WebCore/ForwardingHeaders/wtf/MessageQueue.h b/WebCore/ForwardingHeaders/wtf/MessageQueue.h
new file mode 100644 (file)
index 0000000..986cca5
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/MessageQueue.h>
diff --git a/WebCore/ForwardingHeaders/wtf/Threading.h b/WebCore/ForwardingHeaders/wtf/Threading.h
new file mode 100644 (file)
index 0000000..17359e5
--- /dev/null
@@ -0,0 +1 @@
+#include <JavaScriptCore/Threading.h>
index 7a44aaae23aea286c4729794eba75748c22ac6ab..c63c7b8faa213dc66ac958ab4d5601ec4ff5a0ad 100644 (file)
@@ -948,6 +948,7 @@ webkitgtk_sources += \
        WebCore/platform/gtk/Language.cpp \
        WebCore/platform/gtk/LocalizedStringsGtk.cpp \
        WebCore/platform/gtk/LoggingGtk.cpp \
+       WebCore/platform/gtk/MainThreadGtk.cpp \
        WebCore/platform/gtk/MIMETypeRegistryGtk.cpp \
        WebCore/platform/gtk/MouseEventGtk.cpp \
        WebCore/platform/gtk/PasteboardGtk.cpp \
@@ -962,7 +963,6 @@ webkitgtk_sources += \
        WebCore/platform/gtk/SystemTimeGtk.cpp \
        WebCore/platform/gtk/TemporaryLinkStubs.cpp \
        WebCore/platform/text/gtk/TextBreakIteratorInternalICUGtk.cpp \
-       WebCore/platform/gtk/ThreadingGtk.cpp \
        WebCore/platform/gtk/WheelEventGtk.cpp \
        WebCore/platform/gtk/WidgetGtk.cpp \
        WebCore/platform/gtk/gtk2drawing.c \
index 9dff26c71c48fab7660d8d47ed63566787c5270e..c72cfd59de8fe04117fe82d34e3d9fea07e7c276 100644 (file)
@@ -932,6 +932,7 @@ qt-port {
     platform/graphics/qt/SimpleFontDataQt.cpp \
     platform/qt/KURLQt.cpp \
     platform/qt/Localizations.cpp \
+    platform/qt/MainThreadQt.cpp \
     platform/qt/MIMETypeRegistryQt.cpp \
     platform/qt/PasteboardQt.cpp \
     platform/qt/PlatformKeyboardEventQt.cpp \
@@ -951,7 +952,6 @@ qt-port {
     platform/text/qt/TextBoundaries.cpp \
     platform/text/qt/TextBreakIteratorQt.cpp \
     platform/text/qt/TextCodecQt.cpp \
-    platform/qt/ThreadingQt.cpp \
     platform/qt/WheelEventQt.cpp \
     platform/qt/WidgetQt.cpp \
     ../WebKit/qt/WebCoreSupport/ChromeClientQt.cpp \
@@ -967,7 +967,6 @@ qt-port {
     ../WebKit/qt/Api/qwebhistory.cpp \
     ../WebKit/qt/Api/qwebsettings.cpp \
     ../WebKit/qt/Api/qwebhistoryinterface.cpp \
-    platform/ThreadingNone.cpp
 
     unix: SOURCES += platform/qt/SystemTimeQt.cpp
     else: SOURCES += platform/win/SystemTimeWin.cpp
@@ -1038,6 +1037,7 @@ gtk-port {
         platform/gtk/Language.cpp \
         platform/gtk/LocalizedStringsGtk.cpp \
         platform/gtk/LoggingGtk.cpp \
+        platform/gtk/MainThreadGtk.cpp \
         platform/gtk/MIMETypeRegistryGtk.cpp \
         platform/gtk/MouseEventGtk.cpp \
         platform/gtk/PasteboardGtk.cpp \
@@ -1052,7 +1052,6 @@ gtk-port {
         platform/gtk/SystemTimeGtk.cpp \
         platform/gtk/TemporaryLinkStubs.cpp \
         platform/text/gtk/TextBreakIteratorInternalICUGtk.cpp \
-        platform/gtk/ThreadingGtk.cpp \
         platform/gtk/WheelEventGtk.cpp \
         platform/gtk/WidgetGtk.cpp \
         platform/gtk/gtk2drawing.c \
index c808aabf91495381bea324abbcd88fbec6daed32..899d0fefea83cad682ac8dddcbaadbef734bc5a3 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\platform\MessageQueue.h"\r
+                               RelativePath="..\platform\MainThread.h"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath="..\platform\text\TextStyle.h"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath="..\platform\Threading.h"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath="..\platform\Timer.cpp"\r
                                >\r
                                        RelativePath="..\platform\win\Language.cpp"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath="..\platform\win\MainThreadWin.cpp"\r
+                                       >\r
+                               </File>\r
                                <File\r
                                        RelativePath="..\platform\win\MIMETypeRegistryWin.cpp"\r
                                        >\r
                                        RelativePath="..\platform\win\ThreadConditionWin.cpp"\r
                                        >\r
                                </File>\r
-                               <File\r
-                                       RelativePath="..\platform\win\ThreadingWin.cpp"\r
-                                       >\r
-                               </File>\r
                                <File\r
                                        RelativePath="..\platform\win\WCDataObject.cpp"\r
                                        >\r
index 19e159f188243e627e2dfcbc78a3d611214850a3..4f6a6182ce926f18fdfafb887c9ce237555c8dfd 100644 (file)
@@ -93,7 +93,6 @@
                1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2E6E580CC55213004A2062 /* SQLValue.h */; };
                1A2E6E7A0CC556D5004A2062 /* SQLiteAuthorizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */; };
                1A2E6E7B0CC556D5004A2062 /* SQLiteAuthorizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2E6E790CC556D5004A2062 /* SQLiteAuthorizer.h */; };
-               1A2E6FA40CC5795D004A2062 /* ThreadingPthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6FA30CC5795D004A2062 /* ThreadingPthreads.cpp */; };
                1A3178930B20A81600316987 /* SubresourceLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3178920B20A81600316987 /* SubresourceLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1A3417C90CECFF250049CBDE /* JSCustomVoidCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */; };
                1A3417CA0CECFF250049CBDE /* JSCustomVoidCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */; };
                514C767D0CE923A1007EF3CD /* ResourceRequestBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C76680CE923A1007EF3CD /* ResourceRequestBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                514C767E0CE923A1007EF3CD /* ResourceResponseBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 514C76690CE923A1007EF3CD /* ResourceResponseBase.cpp */; };
                514C767F0CE923A1007EF3CD /* ResourceResponseBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 514C766A0CE923A1007EF3CD /* ResourceResponseBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               515378030D52D0630063A78B /* Locker.h in Headers */ = {isa = PBXBuildFile; fileRef = 515378020D52D0630063A78B /* Locker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                515B03990CD1642A00B7EA9C /* SQLStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 515B03970CD1642A00B7EA9C /* SQLStatement.h */; };
                515B039A0CD1642A00B7EA9C /* SQLStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515B03980CD1642A00B7EA9C /* SQLStatement.cpp */; };
                5160300B0CC4251200C8AC25 /* FileSystemPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5160300A0CC4251200C8AC25 /* FileSystemPOSIX.cpp */; };
                51DF6D7E0B92A16D00C2DC85 /* ThreadCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51DF6D800B92A18E00C2DC85 /* ThreadCheck.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */; };
                51E1ECAF0C91C54600DC255B /* AutodrainedPool.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */; };
-               51E1ECB00C91C54600DC255B /* Threading.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51E1ECAE0C91C54600DC255B /* Threading.mm */; };
                51E1ECB30C91C55600DC255B /* AutodrainedPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E1ECB10C91C55600DC255B /* AutodrainedPool.h */; };
-               51E1ECB40C91C55600DC255B /* Threading.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E1ECB20C91C55600DC255B /* Threading.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51E1ECBE0C91C90400DC255B /* IconDatabaseClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E1ECB80C91C90400DC255B /* IconDatabaseClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                51E1ECC00C91C90400DC255B /* IconRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51E1ECBA0C91C90400DC255B /* IconRecord.cpp */; };
                51E1ECC10C91C90400DC255B /* IconRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = 51E1ECBB0C91C90400DC255B /* IconRecord.h */; };
                E1EC299F0BB04C6B00EA187B /* XPathNodeSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1EC299D0BB04C6B00EA187B /* XPathNodeSet.cpp */; };
                E1EC29A00BB04C6B00EA187B /* XPathNodeSet.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EC299E0BB04C6B00EA187B /* XPathNodeSet.h */; };
                E1ED8AC30CC49BE000BFC557 /* CSSPrimitiveValueMappings.h in Headers */ = {isa = PBXBuildFile; fileRef = E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */; };
+               E1EE79370D6C97DE00FEA3BA /* MainThread.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE79360D6C97DE00FEA3BA /* MainThread.h */; };
+               E1EE793A0D6C9B2700FEA3BA /* MainThreadMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1EE79390D6C9B2700FEA3BA /* MainThreadMac.mm */; };
                E1F1E82F0C3C2BB9006DB391 /* XSLTExtensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */; };
                E1F1E8300C3C2BB9006DB391 /* XSLTExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */; };
                E44613A10CD6331000FADA75 /* HTMLAudioElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */; };
                1A2E6E580CC55213004A2062 /* SQLValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLValue.h; path = sql/SQLValue.h; sourceTree = "<group>"; };
                1A2E6E780CC556D5004A2062 /* SQLiteAuthorizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteAuthorizer.cpp; path = sql/SQLiteAuthorizer.cpp; sourceTree = "<group>"; };
                1A2E6E790CC556D5004A2062 /* SQLiteAuthorizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLiteAuthorizer.h; path = sql/SQLiteAuthorizer.h; sourceTree = "<group>"; };
-               1A2E6FA30CC5795D004A2062 /* ThreadingPthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadingPthreads.cpp; path = pthreads/ThreadingPthreads.cpp; sourceTree = "<group>"; };
                1A3178920B20A81600316987 /* SubresourceLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubresourceLoaderClient.h; sourceTree = "<group>"; };
                1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomVoidCallback.h; sourceTree = "<group>"; };
                1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomVoidCallback.cpp; sourceTree = "<group>"; };
                514C766A0CE923A1007EF3CD /* ResourceResponseBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceResponseBase.h; sourceTree = "<group>"; };
                5150C2A10702629000AF642C /* WebDashboardRegion.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDashboardRegion.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                5150C2A50702629800AF642C /* WebDashboardRegion.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebDashboardRegion.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               515378020D52D0630063A78B /* Locker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Locker.h; sourceTree = "<group>"; };
                515B03970CD1642A00B7EA9C /* SQLStatement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLStatement.h; sourceTree = "<group>"; };
                515B03980CD1642A00B7EA9C /* SQLStatement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLStatement.cpp; sourceTree = "<group>"; };
                5160300A0CC4251200C8AC25 /* FileSystemPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemPOSIX.cpp; sourceTree = "<group>"; };
                51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadCheck.h; sourceTree = "<group>"; };
                51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThreadCheck.mm; sourceTree = "<group>"; };
                51E1ECAD0C91C54600DC255B /* AutodrainedPool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutodrainedPool.mm; sourceTree = "<group>"; };
-               51E1ECAE0C91C54600DC255B /* Threading.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Threading.mm; sourceTree = "<group>"; };
                51E1ECB10C91C55600DC255B /* AutodrainedPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutodrainedPool.h; sourceTree = "<group>"; };
-               51E1ECB20C91C55600DC255B /* Threading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Threading.h; sourceTree = "<group>"; };
                51E1ECB80C91C90400DC255B /* IconDatabaseClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconDatabaseClient.h; sourceTree = "<group>"; };
                51E1ECBA0C91C90400DC255B /* IconRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IconRecord.cpp; sourceTree = "<group>"; };
                51E1ECBB0C91C90400DC255B /* IconRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconRecord.h; sourceTree = "<group>"; };
                E1EC299D0BB04C6B00EA187B /* XPathNodeSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XPathNodeSet.cpp; sourceTree = "<group>"; };
                E1EC299E0BB04C6B00EA187B /* XPathNodeSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPathNodeSet.h; sourceTree = "<group>"; };
                E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPrimitiveValueMappings.h; sourceTree = "<group>"; };
+               E1EE79360D6C97DE00FEA3BA /* MainThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainThread.h; sourceTree = "<group>"; };
+               E1EE79390D6C9B2700FEA3BA /* MainThreadMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MainThreadMac.mm; sourceTree = "<group>"; };
                E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTExtensions.cpp; sourceTree = "<group>"; };
                E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTExtensions.h; sourceTree = "<group>"; };
                E446138F0CD6331000FADA75 /* HTMLAudioElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLAudioElement.cpp; sourceTree = "<group>"; };
                        path = icon;
                        sourceTree = "<group>";
                };
-               5154498E0CAA35F600194B2D /* pthreads */ = {
-                       isa = PBXGroup;
-                       children = (
-                               1A2E6FA30CC5795D004A2062 /* ThreadingPthreads.cpp */,
-                       );
-                       name = pthreads;
-                       sourceTree = "<group>";
-               };
                516030090CC4245400C8AC25 /* posix */ = {
                        isa = PBXGroup;
                        children = (
                                06E81EEB0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm */,
                                935207BF09BD412000F2038D /* LocalizedStringsMac.mm */,
                                1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
+                               E1EE79390D6C9B2700FEA3BA /* MainThreadMac.mm */,
                                BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */,
                                A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */,
                                4B2709810AF2E5E00065127F /* PasteboardMac.mm */,
                                84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */,
                                6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */,
                                51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */,
-                               51E1ECAE0C91C54600DC255B /* Threading.mm */,
                                F5517DC2031AB56301A80180 /* WebCoreHistory.h */,
                                F5517DC3031AB56301A80180 /* WebCoreHistory.m */,
                                84B2B1F7056BEF3A00D2B771 /* WebCoreKeyGenerator.h */,
                                6582A14809999D6C00BEEB6D /* mac */,
                                656B84D70AEA1CE900A095B4 /* network */,
                                516030090CC4245400C8AC25 /* posix */,
-                               5154498E0CAA35F600194B2D /* pthreads */,
                                1A2E6E560CC551E0004A2062 /* sql */,
                                B2C3D9EC0D006C1D00EF6F26 /* text */,
                                BCFB2F74097A2E1A00BA703D /* Arena.cpp */,
                                6593923609AE4346002C531F /* KURL.h */,
                                85EC9AF90A71A2C600EEEAED /* Language.h */,
                                935207BD09BD410A00F2038D /* LocalizedStrings.h */,
-                               515378020D52D0630063A78B /* Locker.h */,
                                A8239DFE09B3CF8A00B60641 /* Logging.cpp */,
                                A8239DFF09B3CF8A00B60641 /* Logging.h */,
+                               E1EE79360D6C97DE00FEA3BA /* MainThread.h */,
                                E1DE1C070D5CE4CF0034C38F /* MessageQueue.h */,
                                BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */,
                                BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */,
                                9352071709BD3BA500F2038D /* StaticConstructors.h */,
                                93E62D990985F41600E1B5E3 /* SystemTime.h */,
                                51DF6D7D0B92A16D00C2DC85 /* ThreadCheck.h */,
-                               51E1ECB20C91C55600DC255B /* Threading.h */,
                                93309EA1099EB78C0056E581 /* Timer.cpp */,
                                9305B24C098F1B6B00C28855 /* Timer.h */,
                                1419D2C40CEA6F6100FF507A /* TreeShared.h */,
                                93F198F608245E59001E9ABC /* TextResourceDecoder.h in Headers */,
                                B2C3DA4B0D006C1D00EF6F26 /* TextStream.h in Headers */,
                                51DF6D7E0B92A16D00C2DC85 /* ThreadCheck.h in Headers */,
-                               51E1ECB40C91C55600DC255B /* Threading.h in Headers */,
                                E44613B00CD6331000FADA75 /* TimeRanges.h in Headers */,
                                B28C6A2E0D00C44800334AA4 /* TimeScheduler.h in Headers */,
                                9305B24D098F1B6B00C28855 /* Timer.h in Headers */,
                                B237C8A80D344D110013F707 /* SVGFontData.h in Headers */,
                                E4EEFFC90D34550C00469A58 /* JSAudioConstructor.h in Headers */,
                                939B3E4E0D3C1E8400B4A92B /* StringBuffer.h in Headers */,
-                               515378030D52D0630063A78B /* Locker.h in Headers */,
                                514075C60D53ECFE00BC2D85 /* SecurityOriginHash.h in Headers */,
                                51A9267D0D53F0570063ECC2 /* OriginQuotaManager.h in Headers */,
                                51A9267F0D53F0570063ECC2 /* OriginUsageRecord.h in Headers */,
                                BCC573350D695BBE006EF517 /* DOMProgressEvent.h in Headers */,
                                BCC573380D695BD7006EF517 /* DOMProgressEventInternal.h in Headers */,
                                BCC5733A0D695BF1006EF517 /* DOMTextPrivate.h in Headers */,
+                               E1EE79370D6C97DE00FEA3BA /* MainThread.h in Headers */,
                                A77979170D6B9D0C003851B9 /* CanvasPixelArray.h in Headers */,
                                A779791A0D6B9D0C003851B9 /* ImageData.h in Headers */,
                                A77979270D6B9E64003851B9 /* JSCanvasPixelArray.h in Headers */,
                                93F19A9D08245E59001E9ABC /* TextResourceDecoder.cpp in Sources */,
                                B2C3DA4A0D006C1D00EF6F26 /* TextStream.cpp in Sources */,
                                51DF6D800B92A18E00C2DC85 /* ThreadCheck.mm in Sources */,
-                               51E1ECB00C91C54600DC255B /* Threading.mm in Sources */,
-                               1A2E6FA40CC5795D004A2062 /* ThreadingPthreads.cpp in Sources */,
                                E44613AF0CD6331000FADA75 /* TimeRanges.cpp in Sources */,
                                B28C6A2D0D00C44800334AA4 /* TimeScheduler.cpp in Sources */,
                                93309EA4099EB78C0056E581 /* Timer.cpp in Sources */,
                                C0294DF30D5A6FD800CC7D6B /* UserStyleSheetLoader.cpp in Sources */,
                                37F818FE0D657606005E1F05 /* WebCoreURLResponse.mm in Sources */,
                                BCC573360D695BBE006EF517 /* DOMProgressEvent.mm in Sources */,
+                               E1EE793A0D6C9B2700FEA3BA /* MainThreadMac.mm in Sources */,
                                A77979160D6B9D0C003851B9 /* CanvasPixelArray.cpp in Sources */,
                                A77979190D6B9D0C003851B9 /* ImageData.cpp in Sources */,
                                A77979260D6B9E64003851B9 /* JSCanvasPixelArray.cpp in Sources */,
index a2ffafa899b9d0a9a0e052973ba7bbafafa4f9e8..a0de7e6b7311e681ea478e7429fb33a9460d3fb8 100644 (file)
@@ -602,7 +602,6 @@ This file contains the list of files needed to build WebCore.
         platform/text/TextEncoding.cpp
         platform/text/TextEncodingRegistry.cpp
         platform/text/TextStream.cpp
-        platform/ThreadingNone.cpp
         platform/Timer.cpp
         platform/Widget.cpp
         platform/graphics/AffineTransform.cpp
index b63144c7529eeba3dcc643dc11cba57433a4d613..cd50ebd4b6996f0b0d8cc36a2e76177745481f75 100644 (file)
@@ -32,6 +32,7 @@
 #include "CString.h"
 #include "Frame.h"
 #include "Logging.h"
+#include "MainThread.h"
 #include "kjs_proxy.h"
 #include "JSSQLTransaction.h"
 #include "Page.h"
index 504063e11b60cdd3e0807328fe91555813917b30..de9df0f2192a804079840760631502751315d61e 100644 (file)
@@ -45,7 +45,6 @@
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
 #include "ResourceResponse.h"
-#include "Threading.h"
 #ifndef USE_QXMLSTREAM
 #include <libxml/parser.h>
 #include <libxml/parserInternals.h>
@@ -54,6 +53,7 @@
 #endif
 #include <wtf/Platform.h>
 #include <wtf/StringExtras.h>
+#include <wtf/Threading.h>
 #include <wtf/Vector.h>
 
 #if ENABLE(XSLT)
index 190f3eec0d1c29e4f539b61c1e97f4d307879baf..a5dfb2596ce9cdda5c23366f4f4bf0973c6b4bb5 100644 (file)
@@ -37,6 +37,7 @@
 #include "IntSize.h"
 #include "KURL.h"
 #include "Logging.h"
+#include "MainThread.h"
 #include "PageURLRecord.h"
 #include "SQLiteStatement.h"
 #include "SQLiteTransaction.h"
@@ -101,7 +102,7 @@ static IconDatabaseClient* defaultClient()
 IconDatabase* iconDatabase()
 {
     if (!sharedIconDatabase) {
-        initializeThreading();
+        initializeThreadingAndMainThread();
         sharedIconDatabase = new IconDatabase;
     }
     return sharedIconDatabase;
index ea48c16bfd992b7d909fc4b1a6d6f92cd5b81f5a..bdd24557db1f0e48f57de21192ceb480b5f37f31 100644 (file)
 #endif
 
 #include "StringHash.h"
-#if ENABLE(ICONDATABASE)
-#include "Threading.h"
-#endif
 #include "Timer.h"
 #include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/OwnPtr.h>
+#if ENABLE(ICONDATABASE)
+#include <wtf/Threading.h>
+#endif
 
 namespace WebCore { 
 
diff --git a/WebCore/platform/MainThread.h b/WebCore/platform/MainThread.h
new file mode 100644 (file)
index 0000000..55758ea
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MainThread_h
+#define MainThread_h
+
+#include <wtf/Threading.h>
+
+namespace WebCore {
+
+typedef void MainThreadFunction(void*);
+
+void callOnMainThread(MainThreadFunction*, void* context);
+
+void initializeThreadingAndMainThread();
+
+#if !PLATFORM(WIN)
+inline void initializeThreadingAndMainThread()
+{
+    WTF::initializeThreading();
+}
+#endif
+
+
+} // namespace WebCore
+
+#endif // MainThread_h
index bb9ae1247e2a6340e3aa297b4c1d8eabfc3e269b..6f7e6f5b9d33075c33a0d1911a553499921c8a04 100644 (file)
@@ -31,9 +31,9 @@
 
 #include <wtf/RefCounted.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/Threading.h>
 
 #include "PlatformString.h"
-#include "Threading.h"
 
 namespace WebCore {
 
diff --git a/WebCore/platform/gtk/MainThreadGtk.cpp b/WebCore/platform/gtk/MainThreadGtk.cpp
new file mode 100644 (file)
index 0000000..db3a583
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MainThread.h"
+
+#include <glib.h>
+
+namespace WebCore {
+
+struct FunctionWithContext {
+    MainThreadFunction* function;
+    void* context;
+};
+
+static gboolean callFunctionOnMainThread(gpointer data)
+{
+    FunctionWithContext* functionWithContext = static_cast<FunctionWithContext*>(data);
+    functionWithContext->function(functionWithContext->context);
+    delete functionWithContext;
+    return FALSE;
+}
+
+void callOnMainThread(MainThreadFunction* function, void* context)
+{
+    ASSERT(function);
+    FunctionWithContext* functionWithContext = new FunctionWithContext;
+    functionWithContext->function = function;
+    functionWithContext->context = context;
+    g_timeout_add(0, callFunctionOnMainThread, functionWithContext);
+}
+
+
+}
similarity index 99%
rename from WebCore/platform/mac/Threading.mm
rename to WebCore/platform/mac/MainThreadMac.mm
index 02d39a36ed84cc4cc2e94a554dd60093b22179d0..47329ef4a804460cec77c1437ea524dd7cc2df2c 100644 (file)
@@ -27,7 +27,7 @@
  */
  
 #import "config.h"
-#import "Threading.h"
+#import "MainThread.h"
 
 @interface WebCoreFunctionWrapper : NSObject {
     WebCore::MainThreadFunction* m_function;
similarity index 98%
rename from WebCore/platform/qt/ThreadingQt.cpp
rename to WebCore/platform/qt/MainThreadQt.cpp
index 71cd17e3e745f3e134e1c05d9380223d2dd0b6f2..ab19bf7269d238e2fc671c1de063b9f3d2477888 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 #include "config.h"
-#include "Threading.h"
+#include "MainThread.h"
 
 #include <QtCore/QObject>
 #include <QtCore/QCoreApplication>
@@ -94,4 +94,4 @@ void callOnMainThread(MainThreadFunction* function, void* context)
 
 }
 
-#include "ThreadingQt.moc"
+#include "MainThreadQt.moc"
index ae2432dab537385b6e8079c008a642f039ab7eac..7d85051a3c68106ac78883f5c7fd7ec3eb83e2ff 100644 (file)
@@ -30,7 +30,7 @@
 #define SQLValue_h
 
 #include "PlatformString.h"
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index 4c0e8eebbed2858463638470ad371f3e4d9a0628..0bb0fb340ba21ee81ffd206cb6dc808b00af9425 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef SQLiteAuthorizer_h
 #define SQLiteAuthorizer_h
 
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index 5e6ab46e2513ccb7898eb5698df2b08287eee448..20f461db711812d94fb7d1be82baa275b74e4b43 100644 (file)
@@ -28,7 +28,7 @@
 #define SQLDatabase_h
 
 #include "PlatformString.h"
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 #if COMPILER(MSVC)
 #pragma warning(disable: 4800)
similarity index 63%
rename from WebCore/platform/win/ThreadingWin.cpp
rename to WebCore/platform/win/MainThreadWin.cpp
index 0da3d1784b76c6259e8b215906a9a7e05efa9fc6..6d3493cff5b92fe040f2b1a833b0375c6bfcc41f 100644 (file)
  */
 
 #include "config.h"
+#include "MainThread.h"
+
 #include "Logging.h"
 #include "Page.h"
-#include "Threading.h"
-#include <errno.h>
 #include <windows.h>
-#include <wtf/HashMap.h>
 
 namespace WebCore {
 
@@ -49,88 +48,6 @@ static UINT threadingFiredMessage = 0;
 const LPCWSTR kThreadingWindowClassName = L"ThreadingWindowClass";
 static bool processingCustomThreadingMessage = false;
 
-static Mutex& threadMapMutex()
-{
-    static Mutex mutex;
-    return mutex;
-}
-
-static HashMap<DWORD, HANDLE>& threadMap()
-{
-    static HashMap<DWORD, HANDLE> map;
-    return map;
-}
-
-static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle)
-{
-    MutexLocker locker(threadMapMutex());
-    threadMap().add(threadID, threadHandle);
-}
-
-static HANDLE threadHandleForIdentifier(ThreadIdentifier id)
-{
-    MutexLocker locker(threadMapMutex());
-    return threadMap().get(id);
-}
-
-static void clearThreadHandleForIdentifier(ThreadIdentifier id)
-{
-    MutexLocker locker(threadMapMutex());
-    ASSERT(threadMap().contains(id));
-    threadMap().remove(id);
-}
-
-ThreadIdentifier createThread(ThreadFunction entryPoint, void* data)
-{
-    DWORD threadIdentifier = 0;
-    ThreadIdentifier threadID = 0;
-    HANDLE hEvent = ::CreateEvent(0, FALSE, FALSE, 0);
-    HANDLE threadHandle = ::CreateThread(0, 0, (LPTHREAD_START_ROUTINE)entryPoint, data, 0, &threadIdentifier);
-    if (!threadHandle) {
-        LOG_ERROR("Failed to create thread at entry point %p with data %p", entryPoint, data);
-        return 0;
-    }
-
-    threadID = static_cast<ThreadIdentifier>(threadIdentifier);
-    storeThreadHandleByIdentifier(threadIdentifier, threadHandle);
-
-    LOG(Threading, "Created thread with thread id %u", threadID);
-    return threadID;
-}
-
-int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
-{
-    ASSERT(threadID);
-    
-    HANDLE threadHandle = threadHandleForIdentifier(threadID);
-    if (!threadHandle)
-        LOG_ERROR("ThreadIdentifier %u did not correspond to an active thread when trying to quit", threadID);
-    DWORD joinResult = ::WaitForSingleObject(threadHandle, INFINITE);
-    if (joinResult == WAIT_FAILED)
-        LOG_ERROR("ThreadIdentifier %u was found to be deadlocked trying to quit", threadID);
-
-    ::CloseHandle(threadHandle);
-    clearThreadHandleForIdentifier(threadID);
-
-    return joinResult;
-}
-
-void detachThread(ThreadIdentifier threadID)
-{
-    ASSERT(threadID);
-    
-    HANDLE threadHandle = threadHandleForIdentifier(threadID);
-    if (threadHandle)
-        ::CloseHandle(threadHandle);
-    clearThreadHandleForIdentifier(threadID);
-}
-
-ThreadIdentifier currentThread()
-{
-    return static_cast<ThreadIdentifier>(::GetCurrentThreadId());
-}
-
 static Mutex& functionQueueMutex()
 {
     static Mutex staticFunctionQueueMutex;
@@ -167,11 +84,13 @@ LRESULT CALLBACK ThreadingWindowWndProc(HWND hWnd, UINT message, WPARAM wParam,
     return 0;
 }
 
-void initializeThreading()
+void initializeThreadingAndMainThread()
 {
     if (threadingWindowHandle)
         return;
-    
+
+    WTF::initializeThreading();
+
     WNDCLASSEX wcex;
     memset(&wcex, 0, sizeof(WNDCLASSEX));
     wcex.cbSize = sizeof(WNDCLASSEX);
similarity index 98%
rename from WebCore/platform/wx/ThreadingWx.cpp
rename to WebCore/platform/wx/MainThreadWx.cpp
index 7cb90ff2e8020af25f3ab9983b33cf13d18a8c56..b49cb62e03f455690fc49834edd2120296dd7e99 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "config.h"
 #include "NotImplemented.h"
-#include "Threading.h"
+#include "MainThread.h"
 
 namespace WebCore {
 
index efe3f25b7b697f4f7393aac0a0c7615471bd4693..927d1990bbd0de06a20f7a87c11f0e16aafa1e37 100644 (file)
@@ -41,6 +41,7 @@
 #include "Frame.h"
 #include "InspectorController.h"
 #include "Logging.h"
+#include "MainThread.h"
 #include "NotImplemented.h"
 #include "Page.h"
 #include "OriginQuotaManager.h"
@@ -123,7 +124,7 @@ Database::Database(Document* document, const String& name, const String& expecte
     if (m_name.isNull())
         m_name = "";
 
-    initializeThreading();
+    initializeThreadingAndMainThread();
 
     m_guid = guidForOriginAndName(m_securityOrigin->toString(), name);
 
index 99be3703417bb6f0c022633d2bcc226f6ae00569..955f0235f327553bd2b60fcf11bac8ae68589d72 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef Database_h
 #define Database_h
 
-#include "MessageQueue.h"
+#include <wtf/MessageQueue.h>
 #include "PlatformString.h"
 #include "SecurityOrigin.h"
 #include "SQLiteDatabase.h"
index 135438a17ad7b7c8b1e82a71bb3a072139505e72..d43090ddbab3de7c2f91011a6f271c56cd0090b6 100644 (file)
@@ -30,9 +30,9 @@
 
 #include "ExceptionCode.h"
 #include "PlatformString.h"
-#include "Threading.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/Threading.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
index a95ca37b1d0841e5a387c91b873357fc877e965c..e61241501161dacff5ed9cb9c229ac8107b327dc 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef DatabaseThread_h
 #define DatabaseThread_h
 
-#include "MessageQueue.h"
+#include <wtf/MessageQueue.h>
 
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
index c4595e948d25a9031cc10155b270f4a8680345a7..ffdd5898b3be06a8768ab33685bd7166d03eceee 100644 (file)
@@ -35,6 +35,7 @@
 #include "Document.h"
 #include "FileSystem.h"
 #include "Logging.h"
+#include "MainThread.h"
 #include "OriginQuotaManager.h"
 #include "Page.h"
 #include "SecurityOrigin.h"
index 874b3f3532e5cd4d8f64fcac2a9427ae162968dd..3191a581b0cf7378d9c724cd4b0d41422e261937 100644 (file)
@@ -31,8 +31,8 @@
 #include "PlatformString.h"
 #include "StringHash.h"
 #include "SecurityOriginHash.h"
-#include "Threading.h"
 #include <wtf/HashMap.h>
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index ddeebc525bc2599dd2c59d0da3eb5f2c70cf5281..5e952e900e5fc7c4ab80d767369785b8fdd51d42 100644 (file)
@@ -30,7 +30,7 @@
 #define SQLError_h
 
 #include "PlatformString.h"
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index de7a2be7685083a5befb26f5b8836693c68ae0dd..e10befe197084ff43913487499a92509d178ad7e 100644 (file)
@@ -30,7 +30,7 @@
 #define SQLResultSet_h
 
 #include "SQLResultSetRowList.h"
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index 538f645db164362aa97626f90a8a9bec6a8c93ad..f2fe36f79451032878a05ca61ee470697419bdef 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef SQLStatment_h
-#define SQLStatment_h
+#ifndef SQLStatement_h
+#define SQLStatement_h
 
 #include "PlatformString.h"
-#include "Threading.h"
 
 #include "SQLError.h"
 #include "SQLResultSet.h"
@@ -39,6 +38,7 @@
 
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
+#include <wtf/Threading.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -78,4 +78,4 @@ private:
 
 } // namespace WebCore
 
-#endif // SQLStatment_h
+#endif // SQLStatement_h
index 9a4b0599585574b80dcaa44ddc02cc8841a7e723..58a94364ae692b2b11fbbb3437306a832efea877 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef SQLStatementCallback_h
 #define SQLStatementCallback_h
 
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index 37ad2317b45ef7bb4b9aee31e9cf7cec26879736..5dc3f5a67bbbeb3f90701a96ac7c0503799aea58 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef SQLStatementErrorCallback_h
 #define SQLStatementErrorCallback_h
 
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index 50dc0d28862616d2b5eb6fe35a1bdcffc2d3e5c1..2d83cc84d91a59caedc90db300d45c67fa73d32a 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef SQLTransaction_h
 #define SQLTransaction_h
 
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 #include "SQLiteTransaction.h"
 #include "SQLStatement.h"
index 0affd1b41fa1628a2b88ade64a36742b2f60e37d..bbe62a5314ec935d23bbaf8a0d796fb6fd83b8ae 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef SQLTransactionCallback_h
 #define SQLTransactionCallback_h
 
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
index 73be74d084ae17d55de399967c960a921078389e..2890556a7110b4c5701a777d36a99bc0db1f0da3 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef SQLTransactionErrorCallback_h
 #define SQLTransactionErrorCallback_h
 
-#include "Threading.h"
+#include <wtf/Threading.h>
 
 namespace WebCore {
     
index 6f5044ad59040076f51ba7530cfc1412570969d7..af732c7d5680af79debd832efc771a1ebe26130f 100644 (file)
@@ -79,6 +79,7 @@ wxWebCore port Bakefile project file.
             platform/wx/LocalizedStringsWx.cpp
             platform/wx/LoggingWx.cpp
             platform/wx/MimeTypeRegistryWx.cpp
+            platform/wx/MainThreadWx.cpp
             platform/wx/MouseEventWx.cpp
             platform/wx/MouseWheelEventWx.cpp
             platform/wx/PasteboardWx.cpp
@@ -88,7 +89,6 @@ wxWebCore port Bakefile project file.
             platform/wx/SoundWx.cpp
             platform/text/wx/StringWx.cpp
             platform/wx/SystemTimeWx.cpp
-            platform/wx/ThreadingWx.cpp
             platform/wx/WidgetWx.cpp
            
             <!-- files from other ports we currently rely on -->
index c9189ef9cd404010843dfcf0021e9052c61a65b6..576b3b9faa8cfd073779d0e50418cdd5cb702c97 100644 (file)
@@ -1,3 +1,12 @@
+2008-02-23  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        Move basic threading support from WebCore to WTF.
+
+        * ForwardingHeaders/wtf/Threading.h: Added.
+        * ForwardingHeaders/wtf/Locker.h: Added.
+
 2008-02-23  David Kilzer  <ddkilzer@apple.com>
 
         Please clarify licensing for some files
diff --git a/WebKit/mac/ForwardingHeaders/wtf/Locker.h b/WebKit/mac/ForwardingHeaders/wtf/Locker.h
new file mode 100644 (file)
index 0000000..7718305
--- /dev/null
@@ -0,0 +1 @@
+#import <JavaScriptCore/Locker.h>
diff --git a/WebKit/mac/ForwardingHeaders/wtf/Threading.h b/WebKit/mac/ForwardingHeaders/wtf/Threading.h
new file mode 100644 (file)
index 0000000..771edd1
--- /dev/null
@@ -0,0 +1 @@
+#import <JavaScriptCore/Threading.h>