Ignore:
Timestamp:
Feb 25, 2010, 10:27:45 AM (15 years ago)
Author:
[email protected]
Message:

Make the context that was passed to the ThreadFunction accessible.
https://bugs.webkit.org/show_bug.cgi?id=35379

Patch by Jochen Eisinger <[email protected]> on 2010-02-25
Reviewed by Jeremy Orlow.

When a database is opened, right now you
don't have any context from where it is opened. The problem is that
the actual calls that open a database go through the sqlite3 vfs
layer, so there's no easy way to pass this function down to to
platform/sql/chromium/SQLFileSystemChromium*.cpp

This patch will allow you to get from anywhere within webkit a pointer
to the Thread object that actually created the thread you're currently
on (in case of the database, this can be either a thread forked of
from the main thread or from a worker thread), and query the object
for context information.

  • wtf/Threading.h:
  • wtf/ThreadingNone.cpp:

(WTF::threadContext):

  • wtf/ThreadingPthreads.cpp:

(WTF::):
(WTF::identifierByPthreadHandle):
(WTF::establishIdentifierForPthreadHandle):
(WTF::pthreadHandleForIdentifier):
(WTF::contextForIdentifier):
(WTF::createThreadInternal):
(WTF::currentThread):
(WTF::threadContext):

  • wtf/ThreadingWin.cpp:

(WTF::):
(WTF::threadMap):
(WTF::storeThreadHandleByIdentifier):
(WTF::threadHandleForIdentifier):
(WTF::contextForIdentifier):
(WTF::createThreadInternal):
(WTF::threadContext):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/ThreadingWin.cpp

    r55246 r55247  
    119119#pragma pack(pop)
    120120
     121typedef struct {
     122    HANDLE handle;
     123    void* context;
     124} ThreadInfo;
     125
    121126void initializeCurrentThreadInternal(const char* szThreadName)
    122127{
     
    166171}
    167172
    168 static HashMap<DWORD, HANDLE>& threadMap()
    169 {
    170     static HashMap<DWORD, HANDLE> map;
     173static HashMap<DWORD, ThreadInfo>& threadMap()
     174{
     175    static HashMap<DWORD, ThreadInfo> map;
    171176    return map;
    172177}
    173178
    174 static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle)
     179static void storeThreadHandleByIdentifier(DWORD threadID, HANDLE threadHandle, void* context)
    175180{
    176181    MutexLocker locker(threadMapMutex());
    177182    ASSERT(!threadMap().contains(threadID));
    178     threadMap().add(threadID, threadHandle);
     183    ThreadInfo info;
     184    info.handle = threadHandle;
     185    info.context = context;
     186    threadMap().add(threadID, info);
    179187}
    180188
     
    182190{
    183191    MutexLocker locker(threadMapMutex());
    184     return threadMap().get(id);
     192    return threadMap().get(id).handle;
     193}
     194
     195static void* contextForIdentifier(ThreadIdentifier id)
     196{
     197    MutexLocker locker(threadMapMutex());
     198    return threadMap().get(id).context;
    185199}
    186200
     
    238252
    239253    threadID = static_cast<ThreadIdentifier>(threadIdentifier);
    240     storeThreadHandleByIdentifier(threadIdentifier, threadHandle);
     254    storeThreadHandleByIdentifier(threadIdentifier, threadHandle, data);
    241255
    242256    return threadID;
     
    279293{
    280294    return currentThread() == mainThreadIdentifier;
     295}
     296
     297void* threadContext(ThreadIdentifier threadID)
     298{
     299    return contextForIdentifier(threadID);
    281300}
    282301
Note: See TracChangeset for help on using the changeset viewer.