Changeset 27707 in webkit
- Timestamp:
- Nov 11, 2007 9:54:59 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r27706 r27707 1 2007-11-11 Justin Haygood <jhaygood@reaktix.com> 2 3 Reviewed by Adam Roben. 4 5 http://bugs.webkit.org/show_bug.cgi?id=15939 6 Adds a currentThread API for use by SQLiteDatabase, etc. 7 8 * platform/Threading.h: 9 * platform/ThreadingNone.cpp: 10 (WebCore::currentThread): 11 * platform/gtk/ThreadingGtk.cpp: 12 (WebCore::identifierByGthreadHandle): 13 (WebCore::): 14 * platform/pthreads/ThreadingPthreads.cpp: 15 (WebCore::identifierByPthreadHandle): 16 (WebCore::currentThread): 17 1 18 2007-11-11 Dan Bernstein <mitz@apple.com> 2 19 -
trunk/WebCore/platform/Threading.h
r26864 r27707 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 42 43 #endif 43 44 45 #if PLATFORM(QT) 46 class QMutex; 47 class QWaitCondition; 48 #endif 49 44 50 #include <stdint.h> 45 51 … … 51 57 // Returns 0 if thread creation failed 52 58 ThreadIdentifier createThread(ThreadFunction, void*); 59 ThreadIdentifier currentThread(); 53 60 int waitForThreadCompletion(ThreadIdentifier, void**); 54 61 void detachThread(ThreadIdentifier); … … 60 67 typedef GMutex* PlatformMutex; 61 68 typedef GCond* PlatformCondition; 69 #elif PLATFORM(QT) 70 typedef QMutex* PlatformMutex; 71 typedef QWaitCondition* PlatformCondition; 62 72 #else 63 73 typedef void* PlatformMutex; -
trunk/WebCore/platform/ThreadingNone.cpp
r26722 r27707 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 34 35 int waitForThreadCompletion(ThreadIdentifier, void**) { return 0; } 35 36 void detachThread(ThreadIdentifier) { } 37 ThreadIdentifier currentThread() { return 0; } 36 38 37 39 Mutex::Mutex() {} -
trunk/WebCore/platform/gtk/ThreadingGtk.cpp
r26864 r27707 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 80 81 } 81 82 83 static ThreadIdentifier identifierByGthreadHandle(GThread*& thread) 84 { 85 MutexLocker locker(threadMapMutex()); 86 87 HashMap<ThreadIdentifier, GThread*>::iterator i = threadMap().begin(); 88 for (; i != threadMap().end(); ++i) { 89 if (i->second == thread) 90 return i->first; 91 } 92 93 return 0; 94 } 95 82 96 static GThread* threadForIdentifier(ThreadIdentifier id) 83 97 { … … 125 139 } 126 140 141 ThreadIdentifier currentThread() 142 { 143 GThread* currentThread = g_thread_self(); 144 if (ThreadIdentifier id = identifierByGthreadHandle(currentThread)) 145 return id; 146 return establishIdentifierForThread(currentThread); 147 } 148 127 149 Mutex::Mutex() 128 150 : m_mutex(g_mutex_new()) -
trunk/WebCore/platform/pthreads/ThreadingPthreads.cpp
r26824 r27707 1 1 /* 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 59 60 } 60 61 62 static ThreadIdentifier identifierByPthreadHandle(const pthread_t& pthreadHandle) 63 { 64 MutexLocker locker(threadMapMutex()); 65 66 HashMap<ThreadIdentifier, pthread_t>::iterator i = threadMap().begin(); 67 for (; i != threadMap().end(); ++i) { 68 if (pthread_equal(i->second, pthreadHandle)) 69 return i->first; 70 } 71 72 return 0; 73 } 74 61 75 static pthread_t pthreadHandleForIdentifier(ThreadIdentifier id) 62 76 { … … 113 127 } 114 128 129 ThreadIdentifier currentThread() 130 { 131 pthread_t currentThread = pthread_self(); 132 if (ThreadIdentifier id = identifierByPthreadHandle(currentThread)) 133 return id; 134 return establishIdentifierForPthreadHandle(currentThread); 135 } 136 115 137 Mutex::Mutex() 116 138 {
Note: See TracChangeset
for help on using the changeset viewer.