Changeset 31579 in vbox for trunk/include/VBox/com
- Timestamp:
- Aug 11, 2010 5:21:27 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64686
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/EventQueue.h
r31372 r31579 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 #define ___VBox_com_EventQueue_h 29 29 30 #if !defined (VBOX_WITH_XPCOM)30 #ifndef VBOX_WITH_XPCOM 31 31 # include <Windows.h> 32 #else 32 #else // VBOX_WITH_XPCOM 33 33 # include <nsEventQueueUtils.h> 34 #endif 34 #endif // VBOX_WITH_XPCOM 35 35 36 36 #include <VBox/com/defs.h> … … 43 43 44 44 /** 45 * Base class for all events. Intended to be subclassed to introduce new events46 * and handlers for them.45 * Base class for all events. Intended to be subclassed to introduce new 46 * events and handlers for them. 47 47 * 48 48 * Subclasses usually reimplement virtual #handler() (that does nothing by … … 74 74 * When using XPCOM, this will map onto the default XPCOM queue for the thread. 75 75 * So, if a queue is created on the main thread, it automatically processes 76 * XPCOM/IPC events while waiting for its own (Event) events.76 * XPCOM/IPC events while waiting. 77 77 * 78 78 * When using Windows, Darwin and OS/2, this will map onto the native thread 79 79 * queue/runloop. So, windows messages and what not will be processed while 80 80 * waiting for events. 81 * 82 * @note It is intentional that there is no way to retrieve arbitrary 83 * events and controlling their processing. There is no use case which 84 * warrants introducing the complexity of platform independent events. 81 85 */ 82 86 class EventQueue … … 87 91 ~EventQueue(); 88 92 89 BOOL postEvent (Event *event); 90 BOOL waitForEvent (Event **event); 91 BOOL handleEvent (Event *event); 93 BOOL postEvent(Event *event); 92 94 int processEventQueue(uint32_t cMsTimeout); 93 95 int interruptEventQueueProcessing(); … … 107 109 static EventQueue *mMainQueue; 108 110 109 #if !defined (VBOX_WITH_XPCOM)111 #ifndef VBOX_WITH_XPCOM 110 112 111 113 /** The thread which the queue belongs to. */ … … 114 116 HANDLE mhThread; 115 117 116 #else 118 #else // VBOX_WITH_XPCOM 117 119 118 120 /** Whether it was created (and thus needs destroying) or if a queue already … … 120 122 BOOL mEQCreated; 121 123 124 /** Whether event processing should be interrupted. */ 125 BOOL mInterrupted; 126 122 127 nsCOMPtr <nsIEventQueue> mEventQ; 123 128 nsCOMPtr <nsIEventQueueService> mEventQService; 124 129 125 Event *mLastEvent;126 BOOL mGotEvent;130 static void *PR_CALLBACK plEventHandler(PLEvent *self); 131 static void PR_CALLBACK plEventDestructor(PLEvent *self); 127 132 128 struct MyPLEvent : public PLEvent 129 { 130 MyPLEvent (Event *e) : event (e) {} 131 Event *event; 132 }; 133 134 static void * PR_CALLBACK plEventHandler (PLEvent* self) 135 { 136 // nsIEventQueue doesn't expose PL_GetEventOwner(), so use an internal 137 // field of PLEvent directly (hackish, but doesn' require an extra lib) 138 EventQueue *owner = (EventQueue *) self->owner; 139 Assert (owner); 140 owner->mLastEvent = ((MyPLEvent *) self)->event; 141 owner->mGotEvent = TRUE; 142 return 0; 143 } 144 145 static void PR_CALLBACK plEventDestructor (PLEvent* self) { delete self; } 146 147 #endif 133 #endif // VBOX_WITH_XPCOM 148 134 }; 149 135
Note:
See TracChangeset
for help on using the changeset viewer.