Changeset 26864 in webkit
- Timestamp:
- Oct 21, 2007 11:26:41 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r26862 r26864 1 2007-10-21 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Alp. 4 5 http://bugs.webkit.org/show_bug.cgi?id=15575 6 Bug 15575: [GTK] Implement threading using GThread 7 8 * wtf/Platform.h: Do not enable pthreads for Gtk. 9 1 10 2007-10-21 Mark Rowe <mrowe@apple.com> 2 11 -
trunk/JavaScriptCore/wtf/Platform.h
r26824 r26864 215 215 #if PLATFORM(GTK) 216 216 #define WTF_USE_CURL 1 217 #define WTF_USE_PTHREADS 1218 217 #endif 219 218 -
trunk/WebCore/ChangeLog
r26857 r26864 1 2007-10-21 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Alp. 4 5 http://bugs.webkit.org/show_bug.cgi?id=15575 6 Bug 15575: [GTK] Implement threading using GThread 7 8 * WebCore.pro: Remove ThreadingPthreads.cpp from the Gtk build and link against libgthreads. 9 * loader/icon/IconDatabase.cpp: Initialize threading before the mutex is created to be compatible with gthreads. 10 (WebCore::iconDatabase): 11 (WebCore::IconDatabase::open): 12 * platform/Threading.h: 13 * platform/gtk/ThreadingGtk.cpp: Threading implementation in terms of GThread, based heavily on the pthreads implementation. 14 (WebCore::initializeThreading): 15 (WebCore::threadMapMutex): 16 (WebCore::threadMap): 17 (WebCore::establishIdentifierForThread): 18 (WebCore::threadForIdentifier): 19 (WebCore::clearThreadForIdentifier): 20 (WebCore::createThread): 21 (WebCore::waitForThreadCompletion): 22 (WebCore::detachThread): 23 (WebCore::Mutex::Mutex): 24 (WebCore::Mutex::~Mutex): 25 (WebCore::Mutex::lock): 26 (WebCore::Mutex::tryLock): 27 (WebCore::Mutex::unlock): 28 (WebCore::ThreadCondition::ThreadCondition): 29 (WebCore::ThreadCondition::~ThreadCondition): 30 (WebCore::ThreadCondition::wait): 31 (WebCore::ThreadCondition::signal): 32 (WebCore::ThreadCondition::broadcast): 33 * storage/Database.cpp: 34 (WebCore::Database::Database): Initialize threading when Database is used so that it will be initialized even 35 if the icon database is compiled out 36 1 37 2007-10-21 Mark Rowe <mrowe@apple.com> 2 38 -
trunk/WebCore/WebCore.pro
r26831 r26864 50 50 QMAKE_LIBDIR_POST += $$split(TMPPATH,";") 51 51 } 52 53 gtk-port: PKGCONFIG += gthread-2.0 52 54 53 55 # Optional components (look for defs in config.h and included files!) … … 950 952 platform/image-decoders/ico/ICOImageDecoder.cpp \ 951 953 platform/image-decoders/xbm/XBMImageDecoder.cpp \ 952 platform/pthreads/ThreadingPthreads.cpp \953 954 ../WebKit/gtk/Api/webkitgtkframe.cpp \ 954 955 ../WebKit/gtk/Api/webkitgtkglobal.cpp \ -
trunk/WebCore/loader/icon/IconDatabase.cpp
r26787 r26864 96 96 IconDatabase* iconDatabase() 97 97 { 98 if (!sharedIconDatabase) 98 if (!sharedIconDatabase) { 99 initializeThreading(); 99 100 sharedIconDatabase = new IconDatabase; 101 } 100 102 return sharedIconDatabase; 101 103 } … … 134 136 // Formulate the full path for the database file 135 137 m_completeDatabasePath = pathByAppendingComponent(m_databaseDirectory, defaultDatabaseFilename()); 136 137 initializeThreading();138 138 139 139 // Lock here as well as first thing in the thread so the tread doesn't actually commence until the pthread_create() call -
trunk/WebCore/platform/Threading.h
r26772 r26864 37 37 #endif 38 38 39 #if PLATFORM(GTK) 40 typedef struct _GMutex GMutex; 41 typedef struct _GCond GCond; 42 #endif 43 39 44 #include <stdint.h> 40 45 … … 48 53 int waitForThreadCompletion(ThreadIdentifier, void**); 49 54 void detachThread(ThreadIdentifier); 55 56 #if USE(PTHREADS) 57 typedef pthread_mutex_t PlatformMutex; 58 typedef pthread_cond_t PlatformCondition; 59 #elif PLATFORM(GTK) 60 typedef GMutex* PlatformMutex; 61 typedef GCond* PlatformCondition; 62 #else 63 typedef void* PlatformMutex; 64 typedef void* PlatformCondition; 65 #endif 50 66 51 67 class Mutex : Noncopyable { … … 57 73 bool tryLock(); 58 74 void unlock(); 59 60 #if USE(PTHREADS) 75 61 76 public: 62 pthread_mutex_t& impl() { return m_mutex; }77 PlatformMutex& impl() { return m_mutex; } 63 78 private: 64 pthread_mutex_t m_mutex; 65 #endif 79 PlatformMutex m_mutex; 66 80 }; 67 81 … … 85 99 86 100 private: 87 #if USE(PTHREADS) 88 pthread_cond_t m_condition; 89 #endif 101 PlatformCondition m_condition; 90 102 }; 91 103 … … 150 162 void initializeThreading(); 151 163 152 #if !PLATFORM(WIN) 164 #if !PLATFORM(WIN) && !PLATFORM(GTK) 153 165 inline void initializeThreading() 154 166 { -
trunk/WebCore/platform/gtk/ThreadingGtk.cpp
r26823 r26864 30 30 #include "Threading.h" 31 31 32 #include "HashMap.h" 32 33 #include "Logging.h" 33 #include "Vector.h"34 34 35 35 #include <glib.h> … … 50 50 } 51 51 52 void initializeThreading() 53 { 54 if (!g_thread_supported()) 55 g_thread_init(NULL); 56 ASSERT(g_thread_supported()); 52 57 } 58 59 static Mutex& threadMapMutex() 60 { 61 static Mutex mutex; 62 return mutex; 63 } 64 65 static HashMap<ThreadIdentifier, GThread*>& threadMap() 66 { 67 static HashMap<ThreadIdentifier, GThread*> map; 68 return map; 69 } 70 71 static ThreadIdentifier establishIdentifierForThread(GThread*& thread) 72 { 73 MutexLocker locker(threadMapMutex()); 74 75 static ThreadIdentifier identifierCount = 1; 76 77 threadMap().add(identifierCount, thread); 78 79 return identifierCount++; 80 } 81 82 static GThread* threadForIdentifier(ThreadIdentifier id) 83 { 84 MutexLocker locker(threadMapMutex()); 85 86 return threadMap().get(id); 87 } 88 89 static void clearThreadForIdentifier(ThreadIdentifier id) 90 { 91 MutexLocker locker(threadMapMutex()); 92 93 ASSERT(threadMap().contains(id)); 94 95 threadMap().remove(id); 96 } 97 98 ThreadIdentifier createThread(ThreadFunction entryPoint, void* data) 99 { 100 GThread* thread; 101 if (!(thread = g_thread_create(entryPoint, data, TRUE, 0))) { 102 LOG_ERROR("Failed to create thread at entry point %p with data %p", entryPoint, data); 103 return 0; 104 } 105 106 ThreadIdentifier threadID = establishIdentifierForThread(thread); 107 LOG(Threading, "Created thread with thread id %u", threadID); 108 return threadID; 109 } 110 111 int waitForThreadCompletion(ThreadIdentifier threadID, void** result) 112 { 113 ASSERT(threadID); 114 115 GThread* thread = threadForIdentifier(threadID); 116 117 *result = g_thread_join(thread); 118 119 clearThreadForIdentifier(threadID); 120 return 0; 121 } 122 123 void detachThread(ThreadIdentifier) 124 { 125 } 126 127 Mutex::Mutex() 128 : m_mutex(g_mutex_new()) 129 { 130 } 131 132 Mutex::~Mutex() 133 { 134 g_mutex_free(m_mutex); 135 } 136 137 void Mutex::lock() 138 { 139 g_mutex_lock(m_mutex); 140 } 141 142 bool Mutex::tryLock() 143 { 144 return g_mutex_trylock(m_mutex); 145 } 146 147 void Mutex::unlock() 148 { 149 g_mutex_unlock(m_mutex); 150 } 151 152 ThreadCondition::ThreadCondition() 153 : m_condition(g_cond_new()) 154 { 155 } 156 157 ThreadCondition::~ThreadCondition() 158 { 159 g_cond_free(m_condition); 160 } 161 162 void ThreadCondition::wait(Mutex& mutex) 163 { 164 g_cond_wait(m_condition, mutex.impl()); 165 } 166 167 void ThreadCondition::signal() 168 { 169 g_cond_signal(m_condition); 170 } 171 172 void ThreadCondition::broadcast() 173 { 174 g_cond_broadcast(m_condition); 175 } 176 177 178 } -
trunk/WebCore/storage/Database.cpp
r26797 r26864 126 126 m_name = ""; 127 127 128 initializeThreading(); 129 128 130 m_guid = guidForOriginAndName(m_securityOrigin.toString(), name); 129 131
Note: See TracChangeset
for help on using the changeset viewer.