Changeset 102016 in vbox for trunk/src/libs/xpcom18a4
- Timestamp:
- Nov 9, 2023 10:30:35 AM (15 months ago)
- Location:
- trunk/src/libs/xpcom18a4/xpcom
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/build/nsXPCOM.h
r101871 r102016 41 41 #include "nscore.h" 42 42 #include "nsXPCOMCID.h" 43 44 #include <iprt/thread.h> 43 45 44 46 #ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP … … 68 70 class nsITraceRefcnt; 69 71 72 typedef RTTHREADINT *RTTHREAD; 73 70 74 #ifdef VBOX 71 75 /** … … 74 78 extern "C" NS_COM PRBool 75 79 NS_IsXPCOMInitialized(void); 80 81 extern "C" NS_COM nsresult 82 NS_GetMainThread(RTTHREAD *phThreadMain); 76 83 #endif 77 84 -
trunk/src/libs/xpcom18a4/xpcom/build/nsXPComInit.cpp
r101944 r102016 74 74 #include "nsIInterfaceInfoManager.h" 75 75 76 #include "nsThread.h"77 78 76 #include "nsEmptyEnumerator.h" 79 77 … … 119 117 120 118 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsEventQueueServiceImpl, Init) 119 120 static RTTHREAD g_hMainThread = 0; 121 121 122 122 #define NS_ENVIRONMENT_CLASSNAME "Environment Service" … … 335 335 COMPONENT(EVENTQUEUESERVICE, nsEventQueueServiceImplConstructor), 336 336 COMPONENT(EVENTQUEUE, nsEventQueueImpl::Create), 337 COMPONENT(THREAD, nsThread::Create),338 337 339 338 #define NS_XPCOMPROXY_CID NS_PROXYEVENT_MANAGER_CID … … 450 449 #endif 451 450 451 nsresult NS_COM 452 NS_GetMainThread(RTTHREAD *phThreadMain) 453 { 454 NS_ASSERTION(phThreadMain, "bad result pointer"); 455 if (g_hMainThread == NIL_RTTHREAD) 456 return NS_ERROR_FAILURE; 457 *phThreadMain = g_hMainThread; 458 return NS_OK; 459 } 460 452 461 nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result, 453 462 nsIFile* binDirectory) … … 470 479 471 480 // Establish the main thread here. 472 rv = nsIThread::SetMainThread(); 473 if (NS_FAILED(rv)) return rv; 481 g_hMainThread = RTThreadSelf(); 474 482 475 483 // If the locale hasn't already been setup by our embedder, … … 872 880 EmptyEnumeratorImpl::Shutdown(); 873 881 874 nsThread::Shutdown();875 882 NS_PurgeAtomTable(); 876 883 -
trunk/src/libs/xpcom18a4/xpcom/threads/nsEventQueue.cpp
r101993 r102016 39 39 #include "nsEventQueue.h" 40 40 #include "nsIEventQueueService.h" 41 #include "nsIThread.h"42 41 43 42 #include "nsIServiceManager.h" … … 125 124 nsEventQueueImpl::Init(PRBool aNative) 126 125 { 127 PRThread *thread = PR_GetCurrentThread();126 RTTHREAD hThread = RTThreadSelf(); 128 127 if (aNative) 129 mEventQueue = PL_CreateNativeEventQueue("Thread event queue...", thread);128 mEventQueue = PL_CreateNativeEventQueue("Thread event queue...", hThread); 130 129 else 131 mEventQueue = PL_CreateMonitoredEventQueue("Thread event queue...", thread);130 mEventQueue = PL_CreateMonitoredEventQueue("Thread event queue...", hThread); 132 131 NotifyObservers(gActivatedNotification); 133 132 return NS_OK; … … 135 134 136 135 NS_IMETHODIMP 137 nsEventQueueImpl::InitFromPRThread( PRThread* thread, PRBool aNative)138 { 139 if ( thread == NS_CURRENT_THREAD)136 nsEventQueueImpl::InitFromPRThread(RTTHREAD hThread, PRBool aNative) 137 { 138 if (hThread == NS_CURRENT_THREAD) 140 139 { 141 thread = PR_GetCurrentThread();142 } 143 else if ( thread == NS_UI_THREAD)140 hThread = RTThreadSelf(); 141 } 142 else if (hThread == NS_UI_THREAD) 144 143 { 145 nsCOMPtr<nsIThread> mainIThread;146 nsresult rv;147 148 144 // Get the primordial thread 149 rv = nsIThread::GetMainThread(getter_AddRefs(mainIThread));145 nsresult rv = NS_GetMainThread(&hThread); 150 146 if (NS_FAILED(rv)) return rv; 151 152 rv = mainIThread->GetPRThread(&thread); 153 if (NS_FAILED(rv)) return rv; 154 } 147 } 155 148 156 149 if (aNative) 157 mEventQueue = PL_CreateNativeEventQueue("Thread event queue...", thread);150 mEventQueue = PL_CreateNativeEventQueue("Thread event queue...", hThread); 158 151 else 159 mEventQueue = PL_CreateMonitoredEventQueue("Thread event queue...", thread);152 mEventQueue = PL_CreateMonitoredEventQueue("Thread event queue...", hThread); 160 153 NotifyObservers(gActivatedNotification); 161 154 return NS_OK; -
trunk/src/libs/xpcom18a4/xpcom/threads/nsEventQueueService.cpp
r101992 r102016 54 54 #include "prmon.h" 55 55 #include "nsIComponentManager.h" 56 #include "nsIThread.h"57 56 #include "nsPIEventQueueChain.h" 57 58 #include "nsXPCOM.h" 58 59 59 60 #include <VBox/log.h> … … 107 108 108 109 // ensure that a main thread event queue exists! 109 nsresult rv; 110 nsCOMPtr<nsIThread> mainThread; 111 rv = nsIThread::GetMainThread(getter_AddRefs(mainThread)); 112 if (NS_SUCCEEDED(rv)) { 113 PRThread *thr; 114 rv = mainThread->GetPRThread(&thr); 115 if (NS_SUCCEEDED(rv)) 116 rv = CreateEventQueue(thr, PR_TRUE); 117 } 110 RTTHREAD hMainThread; 111 nsresult rv = NS_GetMainThread(&hMainThread); 112 if (NS_SUCCEEDED(rv)) 113 rv = CreateEventQueue(hMainThread, PR_TRUE); 114 118 115 return rv; 119 116 } … … 127 124 nsEventQueueServiceImpl::CreateThreadEventQueue() 128 125 { 129 return CreateEventQueue( PR_GetCurrentThread(), PR_TRUE);126 return CreateEventQueue(RTThreadSelf(), PR_TRUE); 130 127 } 131 128 … … 133 130 nsEventQueueServiceImpl::CreateMonitoredThreadEventQueue() 134 131 { 135 return CreateEventQueue( PR_GetCurrentThread(), PR_FALSE);136 } 137 138 NS_IMETHODIMP 139 nsEventQueueServiceImpl::CreateFromIThread( nsIThread *aThread, PRBool aNative,132 return CreateEventQueue(RTThreadSelf(), PR_FALSE); 133 } 134 135 NS_IMETHODIMP 136 nsEventQueueServiceImpl::CreateFromIThread(RTTHREAD aThread, PRBool aNative, 140 137 nsIEventQueue **aResult) 141 138 { 142 139 nsresult rv; 143 PRThread *prThread; 144 145 rv = aThread->GetPRThread(&prThread); 146 if (NS_SUCCEEDED(rv)) { 147 rv = CreateEventQueue(prThread, aNative); // addrefs 148 if (NS_SUCCEEDED(rv)) 149 rv = GetThreadEventQueue(prThread, aResult); // addrefs 150 } 140 141 rv = CreateEventQueue(aThread, aNative); // addrefs 142 if (NS_SUCCEEDED(rv)) 143 rv = GetThreadEventQueue(aThread, aResult); // addrefs 144 151 145 return rv; 152 146 } … … 154 148 // private method 155 149 NS_IMETHODIMP 156 nsEventQueueServiceImpl::MakeNewQueue( PRThread* thread,150 nsEventQueueServiceImpl::MakeNewQueue(RTTHREAD hThread, 157 151 PRBool aNative, 158 152 nsIEventQueue **aQueue) … … 162 156 163 157 if (NS_SUCCEEDED(rv)) { 164 rv = queue->InitFromPRThread( thread, aNative);165 } 158 rv = queue->InitFromPRThread(hThread, aNative); 159 } 166 160 *aQueue = queue; 167 161 NS_IF_ADDREF(*aQueue); … … 171 165 // private method 172 166 NS_IMETHODIMP 173 nsEventQueueServiceImpl::CreateEventQueue( PRThread *aThread, PRBool aNative)167 nsEventQueueServiceImpl::CreateEventQueue(RTTHREAD aThread, PRBool aNative) 174 168 { 175 169 nsresult rv = NS_OK; … … 200 194 PR_EnterMonitor(mEventQMonitor); 201 195 202 PRThread* currentThread = PR_GetCurrentThread();203 nsIEventQueue* queue = mEventQTable.GetWeak( currentThread);196 RTTHREAD hThread = RTThreadSelf(); 197 nsIEventQueue* queue = mEventQTable.GetWeak(hThread); 204 198 if (queue) { 205 199 queue->StopAcceptingEvents(); // tell the queue to stop accepting events 206 200 queue = nsnull; // Queue may die on the next line 207 mEventQTable.Remove( currentThread); // remove nsIEventQueue from hash table (releases)201 mEventQTable.Remove(hThread); // remove nsIEventQueue from hash table (releases) 208 202 } 209 203 … … 256 250 { 257 251 nsresult rv = NS_OK; 258 PRThread* currentThread = PR_GetCurrentThread();252 RTTHREAD hThread = RTThreadSelf(); 259 253 PRBool native = PR_TRUE; // native by default as per old comment 260 254 … … 265 259 PR_EnterMonitor(mEventQMonitor); 266 260 267 nsIEventQueue* queue = mEventQTable.GetWeak( currentThread);261 nsIEventQueue* queue = mEventQTable.GetWeak(hThread); 268 262 269 263 NS_ASSERTION(queue, "pushed event queue on top of nothing"); … … 278 272 279 273 nsIEventQueue* newQueue = nsnull; 280 MakeNewQueue( currentThread, native, &newQueue); // create new queue; addrefs274 MakeNewQueue(hThread, native, &newQueue); // create new queue; addrefs 281 275 282 276 if (!queue) { 283 277 // shouldn't happen. as a fallback, we guess you wanted a native queue 284 mEventQTable.Put( currentThread, newQueue);278 mEventQTable.Put(hThread, newQueue); 285 279 } 286 280 … … 307 301 nsEventQueueServiceImpl::PopThreadEventQueue(nsIEventQueue *aQueue) 308 302 { 309 PRThread* currentThread = PR_GetCurrentThread();303 RTTHREAD hThread = RTThreadSelf(); 310 304 311 305 /* Enter the lock that protects the EventQ hashtable... */ … … 313 307 314 308 nsCOMPtr<nsIEventQueue> eldestQueue; 315 mEventQTable.Get( currentThread, getter_AddRefs(eldestQueue));309 mEventQTable.Get(hThread, getter_AddRefs(eldestQueue)); 316 310 317 311 // If we are popping the eldest queue, remove its mEventQTable entry. 318 312 if (aQueue == eldestQueue) 319 mEventQTable.Remove( currentThread);313 mEventQTable.Remove(hThread); 320 314 321 315 // Exit the monitor before processing pending events to avoid deadlock. … … 338 332 339 333 NS_IMETHODIMP 340 nsEventQueueServiceImpl::GetThreadEventQueue( PRThread*aThread, nsIEventQueue** aResult)334 nsEventQueueServiceImpl::GetThreadEventQueue(RTTHREAD aThread, nsIEventQueue** aResult) 341 335 { 342 336 /* Parameter validation... */ 343 337 if (NULL == aResult) return NS_ERROR_NULL_POINTER; 344 338 345 PRThread*keyThread = aThread;339 RTTHREAD keyThread = aThread; 346 340 347 341 if (keyThread == NS_CURRENT_THREAD) 348 342 { 349 keyThread = PR_GetCurrentThread();343 keyThread = RTThreadSelf(); 350 344 } 351 345 else if (keyThread == NS_UI_THREAD) 352 346 { 353 nsCOMPtr<nsIThread> mainIThread;354 355 347 // Get the primordial thread 356 nsresult rv = nsIThread::GetMainThread(getter_AddRefs(mainIThread)); 357 if (NS_FAILED(rv)) return rv; 358 359 rv = mainIThread->GetPRThread(&keyThread); 348 nsresult rv = NS_GetMainThread(&keyThread); 360 349 if (NS_FAILED(rv)) return rv; 361 350 } -
trunk/src/libs/xpcom18a4/xpcom/threads/nsEventQueueService.h
r1 r102016 65 65 Addref the descriptor in any case. parameter aNative is 66 66 ignored if the queue already exists. */ 67 NS_IMETHOD CreateEventQueue( PRThread *aThread, PRBool aNative);68 NS_IMETHOD MakeNewQueue( PRThread*thread, PRBool aNative, nsIEventQueue **aQueue);67 NS_IMETHOD CreateEventQueue(RTTHREAD aThread, PRBool aNative); 68 NS_IMETHOD MakeNewQueue(RTTHREAD thread, PRBool aNative, nsIEventQueue **aQueue); 69 69 inline nsresult GetYoungestEventQueue(nsIEventQueue *queue, nsIEventQueue **aResult); 70 70 -
trunk/src/libs/xpcom18a4/xpcom/threads/nsIEventQueue.idl
r1 r102016 46 46 47 47 %{C++ 48 #include "prthread.h"48 #include <iprt/thread.h> 49 49 50 50 // {13D86C61-00A9-11d3-9F2A-00400553EEF0} … … 60 60 // 61 61 [ptr] native PLEventQueuePtr(PLEventQueue); 62 [ptr] native PRThreadPtr(PRThread);62 [ptr] native RTTHREAD(RTTHREADINT); 63 63 native PRStatus(PRStatus); 64 64 [ref] native PRBoolRef(PRBool); … … 89 89 90 90 void init(in boolean aNative); 91 [noscript] void initFromPRThread(in PRThreadPtrthread,91 [noscript] void initFromPRThread(in RTTHREAD thread, 92 92 in boolean aNative); 93 93 [noscript] void initFromPLQueue(in PLEventQueuePtr aQueue); -
trunk/src/libs/xpcom18a4/xpcom/threads/nsIEventQueueService.idl
r1 r102016 49 49 50 50 %{C++ 51 #include "prthread.h"52 51 #include "plevent.h" 52 53 #include <iprt/thread.h> 53 54 54 55 /* be761f00-a3b0-11d2-996c-0080c7cb1080 */ … … 60 61 #define NS_EVENTQUEUESERVICE_CLASSNAME "Event Queue Service" 61 62 62 #define NS_CURRENT_THREAD (( PRThread*)0)63 #define NS_CURRENT_THREAD ((RTTHREAD)0) 63 64 #define NS_CURRENT_EVENTQ ((nsIEventQueue*)0) 64 65 65 #define NS_UI_THREAD (( PRThread*)1)66 #define NS_UI_THREAD ((RTTHREAD)1) 66 67 #define NS_UI_THREAD_EVENTQ ((nsIEventQueue*)1) 67 68 68 69 %} 69 70 /* a forward decl */71 interface nsIThread;72 70 73 71 [scriptable, uuid(a6cf90dc-15b3-11d2-932e-00805f8add32)] … … 100 98 void destroyThreadEventQueue(); 101 99 102 nsIEventQueue createFromIThread(in nsIThreadaThread,103 in boolean aNative);100 [noscript] nsIEventQueue createFromIThread(in RTTHREAD aThread, 101 in boolean aNative); 104 102 105 103 [noscript] nsIEventQueue createFromPLEventQueue(in PLEventQueuePtr … … 113 111 void popThreadEventQueue(in nsIEventQueue aQueue); 114 112 115 [noscript] nsIEventQueue getThreadEventQueue(in PRThreadPtraThread);113 [noscript] nsIEventQueue getThreadEventQueue(in RTTHREAD aThread); 116 114 117 115 /** -
trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c
r101990 r102016 74 74 PRCList queue; 75 75 PRMonitor* monitor; 76 PRThread*handlerThread;76 RTTHREAD handlerThread; 77 77 EventQueueType type; 78 78 PRPackedBool processingEvents; … … 111 111 */ 112 112 static PLEventQueue * _pl_CreateEventQueue(const char *name, 113 PRThread *handlerThread,113 RTTHREAD handlerThread, 114 114 EventQueueType qtype) 115 115 { … … 147 147 148 148 PR_IMPLEMENT(PLEventQueue*) 149 PL_CreateEventQueue(const char* name, PRThread*handlerThread)149 PL_CreateEventQueue(const char* name, RTTHREAD handlerThread) 150 150 { 151 151 return( _pl_CreateEventQueue( name, handlerThread, EventQueueIsNative )); … … 153 153 154 154 PR_EXTERN(PLEventQueue *) 155 PL_CreateNativeEventQueue(const char *name, PRThread *handlerThread)155 PL_CreateNativeEventQueue(const char *name, RTTHREAD handlerThread) 156 156 { 157 157 return( _pl_CreateEventQueue( name, handlerThread, EventQueueIsNative )); … … 159 159 160 160 PR_EXTERN(PLEventQueue *) 161 PL_CreateMonitoredEventQueue(const char *name, PRThread *handlerThread)161 PL_CreateMonitoredEventQueue(const char *name, RTTHREAD handlerThread) 162 162 { 163 163 return( _pl_CreateEventQueue( name, handlerThread, EventQueueIsMonitored )); … … 247 247 Assert(event != NULL); 248 248 249 if ( PR_GetCurrentThread() == self->handlerThread) {249 if (RTThreadSelf() == self->handlerThread) { 250 250 /* Handle the case where the thread requesting the event handling 251 251 * is also the thread that's supposed to do the handling. */ … … 590 590 been processed and destroyed or not. */ 591 591 592 Assert(queue->handlerThread == PR_GetCurrentThread());592 Assert(queue->handlerThread == RTThreadSelf()); 593 593 594 594 PR_EnterMonitor(queue->monitor); … … 814 814 PL_IsQueueOnCurrentThread( PLEventQueue *queue ) 815 815 { 816 PRThread *me = PR_GetCurrentThread(); 817 return me == queue->handlerThread; 816 return queue->handlerThread == RTThreadSelf(); 818 817 } 819 818 -
trunk/src/libs/xpcom18a4/xpcom/threads/plevent.h
r101981 r102016 187 187 #include "prtypes.h" 188 188 #include "prclist.h" 189 #include "prthread.h"190 189 #include "prcvar.h" 191 190 #include "prmon.h" … … 193 192 #include <iprt/critsect.h> 194 193 #include <iprt/semaphore.h> 194 #include <iprt/thread.h> 195 195 196 196 #ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP … … 238 238 */ 239 239 PR_EXTERN(PLEventQueue*) 240 PL_CreateEventQueue(const char* name, PRThread*handlerThread);240 PL_CreateEventQueue(const char* name, RTTHREAD handlerThread); 241 241 242 242 … … 261 261 ** name: A name, as a diagnostic aid. 262 262 ** 263 ** handlerThread: A pointer to the PRThread structure for263 ** handlerThread: A pointer to the IPRT thread structure for 264 264 ** the thread that will "handle" events posted to this event 265 265 ** queue. … … 272 272 PL_CreateNativeEventQueue( 273 273 const char *name, 274 PRThread *handlerThread274 RTTHREAD handlerThread 275 275 ); 276 276 … … 290 290 ** name: A name, as a diagnostic aid. 291 291 ** 292 ** handlerThread: A pointer to the PRThread structure for292 ** handlerThread: A pointer to the IPRT thread structure for 293 293 ** the thread that will "handle" events posted to this event 294 294 ** queue. … … 301 301 PL_CreateMonitoredEventQueue( 302 302 const char *name, 303 PRThread *handlerThread303 RTTHREAD handlerThread 304 304 ); 305 305
Note:
See TracChangeset
for help on using the changeset viewer.