Skip to content
Permalink
Browse files
2010-03-02 Jeremy Orlow <jorlow@chromium.org>
        Reviewed by David Levin.

        Revert database thread changes that are no longer required
        https://bugs.webkit.org/show_bug.cgi?id=35519

        Jochen Eisinger created 55214 and 55247 to track which database
        owns which thread.  Dmitry suggested that this could also
        be done via TLS, though.  After exploring the options, Jochen
        chose to go the TLS route, so these patches are no longer needed.

        * wtf/Threading.h:
        * wtf/ThreadingNone.cpp:
        (WTF::isMainThread):
        * wtf/ThreadingPthreads.cpp:
        (WTF::identifierByPthreadHandle):
        (WTF::establishIdentifierForPthreadHandle):
        (WTF::pthreadHandleForIdentifier):
        (WTF::createThreadInternal):
        (WTF::currentThread):
        * wtf/ThreadingWin.cpp:
        (WTF::threadMap):
        (WTF::storeThreadHandleByIdentifier):
        (WTF::threadHandleForIdentifier):
        (WTF::createThreadInternal):
2010-03-02  Jeremy Orlow  <jorlow@chromium.org>

        Reviewed by David Levin.

        Revert database thread changes that are no longer required
        https://bugs.webkit.org/show_bug.cgi?id=35519

        Jochen Eisinger created 55214 and 55247 to track which database
        owns which thread.  Dmitry suggested that this could also
        be done via TLS, though.  After exploring the options, Jochen
        chose to go the TLS route, so these patches are no longer needed.

        * storage/DatabaseThread.cpp:
        (WebCore::DatabaseThread::DatabaseThread):
        (WebCore::DatabaseThread::databaseThread):
        * storage/DatabaseThread.h:
        (WebCore::DatabaseThread::getThreadID):

Canonical link: https://commits.webkit.org/46730@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@55429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Mar 2, 2010
1 parent cc1e256 commit 4ee9ae7e3b6d0de98cc75efb6f7273aaa80e5044
Showing 8 changed files with 59 additions and 63 deletions.
@@ -1,3 +1,30 @@
2010-03-02 Jeremy Orlow <jorlow@chromium.org>

Reviewed by David Levin.

Revert database thread changes that are no longer required
https://bugs.webkit.org/show_bug.cgi?id=35519

Jochen Eisinger created 55214 and 55247 to track which database
owns which thread. Dmitry suggested that this could also
be done via TLS, though. After exploring the options, Jochen
chose to go the TLS route, so these patches are no longer needed.

* wtf/Threading.h:
* wtf/ThreadingNone.cpp:
(WTF::isMainThread):
* wtf/ThreadingPthreads.cpp:
(WTF::identifierByPthreadHandle):
(WTF::establishIdentifierForPthreadHandle):
(WTF::pthreadHandleForIdentifier):
(WTF::createThreadInternal):
(WTF::currentThread):
* wtf/ThreadingWin.cpp:
(WTF::threadMap):
(WTF::storeThreadHandleByIdentifier):
(WTF::threadHandleForIdentifier):
(WTF::createThreadInternal):

2010-03-02 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>

Reviewed by Simon Hausmann.
@@ -127,7 +127,6 @@ ThreadIdentifier currentThread();
bool isMainThread();
int waitForThreadCompletion(ThreadIdentifier, void**);
void detachThread(ThreadIdentifier);
void* threadContext(ThreadIdentifier);

#if USE(PTHREADS)
typedef pthread_mutex_t PlatformMutex;
@@ -41,7 +41,6 @@ int waitForThreadCompletion(ThreadIdentifier, void**) { return 0; }
void detachThread(ThreadIdentifier) { }
ThreadIdentifier currentThread() { return ThreadIdentifier(); }
bool isMainThread() { return true; }
void* threadContext(ThreadIdentifier) { return 0; }

Mutex::Mutex() { }
Mutex::~Mutex() { }
@@ -53,12 +53,7 @@

namespace WTF {

typedef struct {
pthread_t handle;
void* context;
} ThreadInfo;

typedef HashMap<ThreadIdentifier, ThreadInfo> ThreadMap;
typedef HashMap<ThreadIdentifier, pthread_t> ThreadMap;

static Mutex* atomicallyInitializedStaticMutex;

@@ -110,25 +105,22 @@ static ThreadIdentifier identifierByPthreadHandle(const pthread_t& pthreadHandle

ThreadMap::iterator i = threadMap().begin();
for (; i != threadMap().end(); ++i) {
if (pthread_equal(i->second.handle, pthreadHandle))
if (pthread_equal(i->second, pthreadHandle))
return i->first;
}

return 0;
}

static ThreadIdentifier establishIdentifierForPthreadHandle(const pthread_t& pthreadHandle, void* context)
static ThreadIdentifier establishIdentifierForPthreadHandle(const pthread_t& pthreadHandle)
{
ASSERT(!identifierByPthreadHandle(pthreadHandle));

MutexLocker locker(threadMapMutex());

static ThreadIdentifier identifierCount = 1;

ThreadInfo info;
info.handle = pthreadHandle;
info.context = context;
threadMap().add(identifierCount, info);
threadMap().add(identifierCount, pthreadHandle);

return identifierCount++;
}
@@ -137,17 +129,9 @@ static pthread_t pthreadHandleForIdentifier(ThreadIdentifier id)
{
MutexLocker locker(threadMapMutex());

return threadMap().get(id).handle;
}

static void* contextForIdentifier(ThreadIdentifier id)
{
MutexLocker locker(threadMapMutex());

return threadMap().get(id).context;
return threadMap().get(id);
}


void clearPthreadHandleForIdentifier(ThreadIdentifier id)
{
MutexLocker locker(threadMapMutex());
@@ -190,7 +174,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
delete threadData;
return 0;
}
return establishIdentifierForPthreadHandle(threadHandle, data);
return establishIdentifierForPthreadHandle(threadHandle);
}
#else
ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, const char*)
@@ -201,7 +185,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
return 0;
}

return establishIdentifierForPthreadHandle(threadHandle, data);
return establishIdentifierForPthreadHandle(threadHandle);
}
#endif

@@ -251,7 +235,7 @@ ThreadIdentifier currentThread()
return id;

// Not a WTF-created thread, ThreadIdentifier is not established yet.
id = establishIdentifierForPthreadHandle(pthread_self(), 0);
id = establishIdentifierForPthreadHandle(pthread_self());
ThreadIdentifierData::initialize(id);
return id;
}
@@ -265,11 +249,6 @@ bool isMainThread()
#endif
}

void* threadContext(ThreadIdentifier id)
{
return contextForIdentifier(id);
}

Mutex::Mutex()
{
pthread_mutex_init(&m_mutex, NULL);
@@ -118,11 +118,6 @@ typedef struct tagTHREADNAME_INFO {
} THREADNAME_INFO;
#pragma pack(pop)

typedef struct {
HANDLE handle;
void* context;
} ThreadInfo;

void initializeCurrentThreadInternal(const char* szThreadName)
{
THREADNAME_INFO info;
@@ -170,32 +165,23 @@ void initializeThreading()
}
}

static HashMap<DWORD, ThreadInfo>& threadMap()
static HashMap<DWORD, HANDLE>& threadMap()
{
static HashMap<DWORD, ThreadInfo> map;
static HashMap<DWORD, HANDLE> map;
return map;
}

static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle, void* context)
static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle)
{
MutexLocker locker(threadMapMutex());
ASSERT(!threadMap().contains(threadID));
ThreadInfo info;
info.handle = threadHandle;
info.context = context;
threadMap().add(threadID, info);
threadMap().add(threadID, threadHandle);
}

static HANDLE threadHandleForIdentifier(ThreadIdentifier id)
{
MutexLocker locker(threadMapMutex());
return threadMap().get(id).handle;
}

static void* contextForIdentifier(ThreadIdentifier id)
{
MutexLocker locker(threadMapMutex());
return threadMap().get(id).context;
return threadMap().get(id);
}

static void clearThreadHandleForIdentifier(ThreadIdentifier id)
@@ -251,7 +237,7 @@ ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
}

threadID = static_cast<ThreadIdentifier>(threadIdentifier);
storeThreadHandleByIdentifier(threadIdentifier, threadHandle, data);
storeThreadHandleByIdentifier(threadIdentifier, threadHandle);

return threadID;
}
@@ -294,11 +280,6 @@ bool isMainThread()
return currentThread() == mainThreadIdentifier;
}

void* threadContext(ThreadIdentifier threadID)
{
return contextForIdentifier(threadID);
}

Mutex::Mutex()
{
m_mutex.m_recursionCount = 0;
@@ -1,3 +1,21 @@
2010-03-02 Jeremy Orlow <jorlow@chromium.org>

Reviewed by David Levin.

Revert database thread changes that are no longer required
https://bugs.webkit.org/show_bug.cgi?id=35519

Jochen Eisinger created 55214 and 55247 to track which database
owns which thread. Dmitry suggested that this could also
be done via TLS, though. After exploring the options, Jochen
chose to go the TLS route, so these patches are no longer needed.

* storage/DatabaseThread.cpp:
(WebCore::DatabaseThread::DatabaseThread):
(WebCore::DatabaseThread::databaseThread):
* storage/DatabaseThread.h:
(WebCore::DatabaseThread::getThreadID):

2010-03-02 Brady Eidson <beidson@apple.com>

Reviewed by Sam Weinig.
@@ -42,7 +42,6 @@ namespace WebCore {

DatabaseThread::DatabaseThread()
: m_threadID(0)
, m_databaseOfCurrentTask(0)
, m_transactionClient(new SQLTransactionClient())
, m_transactionCoordinator(new SQLTransactionCoordinator())
, m_cleanupSync(0)
@@ -97,10 +96,7 @@ void* DatabaseThread::databaseThread()

AutodrainedPool pool;
while (OwnPtr<DatabaseTask> task = m_queue.waitForMessage()) {
ASSERT(!m_databaseOfCurrentTask);
m_databaseOfCurrentTask = task->database();
task->performTask();
m_databaseOfCurrentTask = 0;
pool.cycle();
}

@@ -64,7 +64,6 @@ class DatabaseThread : public ThreadSafeShared<DatabaseThread> {
void recordDatabaseOpen(Database*);
void recordDatabaseClosed(Database*);
ThreadIdentifier getThreadID() { return m_threadID; }
Database* getDatabaseOfCurrentTask() { return m_databaseOfCurrentTask; }

SQLTransactionClient* transactionClient() { return m_transactionClient.get(); }
SQLTransactionCoordinator* transactionCoordinator() { return m_transactionCoordinator.get(); }
@@ -81,8 +80,6 @@ class DatabaseThread : public ThreadSafeShared<DatabaseThread> {

MessageQueue<DatabaseTask> m_queue;

Database* m_databaseOfCurrentTask;

// This set keeps track of the open databases that have been used on this thread.
typedef HashSet<RefPtr<Database> > DatabaseSet;
DatabaseSet m_openDatabaseSet;

0 comments on commit 4ee9ae7

Please sign in to comment.