Changeset 46649 in vbox for trunk/include/VBox
- Timestamp:
- Jun 19, 2013 11:47:32 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/VBox-4.1 merged: 82579,85941 /branches/VBox-4.2 merged: 86229-86230,86234,86529 /branches/andy/guestctrl20 (added) merged: 78916,78930
- Property svn:mergeinfo changed
-
trunk/include/VBox/com/EventQueue.h
r45125 r46649 1 /* $Id$ */ 1 2 /** @file 2 * MS COM / XPCOM Abstraction Layer - Event and EventQueue class declaration.3 * Event queue class declaration. 3 4 */ 4 5 5 6 /* 6 * Copyright (C) 20 06-2012Oracle Corporation7 * Copyright (C) 2013 Oracle Corporation 7 8 * 8 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 27 28 #define ___VBox_com_EventQueue_h 28 29 29 #ifndef VBOX_WITH_XPCOM 30 # include <Windows.h> 31 #else // VBOX_WITH_XPCOM 32 # include <nsEventQueueUtils.h> 33 #endif // VBOX_WITH_XPCOM 30 #include <list> 31 32 #include <iprt/asm.h> 33 #include <iprt/critsect.h> 34 34 35 35 #include <VBox/com/defs.h> … … 52 52 public: 53 53 54 Event() {} 55 virtual ~Event() {}; 54 Event(void) : 55 mRefCount(0) { } 56 virtual ~Event(void) { AssertMsg(!mRefCount, 57 ("Reference count of event=%p not 0 on destruction (is %RU32)\n", 58 this, mRefCount)); } 59 public: 60 61 uint32_t AddRef(void) { return ASMAtomicIncU32(&mRefCount); } 62 void Release(void) 63 { 64 Assert(mRefCount); 65 uint32_t cRefs = ASMAtomicDecU32(&mRefCount); 66 if (!cRefs) 67 delete this; 68 } 56 69 57 70 protected: … … 63 76 * @return reserved, should be NULL. 64 77 */ 65 virtual void *handler( ) { return NULL; }78 virtual void *handler(void) { return NULL; } 66 79 67 80 friend class EventQueue; 81 82 protected: 83 84 /** The event's reference count. */ 85 uint32_t mRefCount; 68 86 }; 87 88 typedef std::list< Event* > EventQueueList; 89 typedef std::list< Event* >::iterator EventQueueListIterator; 90 typedef std::list< Event* >::const_iterator EventQueueListIteratorConst; 69 91 70 92 /** 71 93 * Simple event queue. 72 *73 * When using XPCOM, this will map onto the default XPCOM queue for the thread.74 * So, if a queue is created on the main thread, it automatically processes75 * XPCOM/IPC events while waiting.76 *77 * When using Windows, Darwin and OS/2, this will map onto the native thread78 * queue/runloop. So, windows messages and what not will be processed while79 * waiting for events.80 *81 * @note It is intentional that there is no way to retrieve arbitrary82 * events and controlling their processing. There is no use case which83 * warrants introducing the complexity of platform independent events.84 94 */ 85 95 class EventQueue … … 87 97 public: 88 98 89 EventQueue(); 90 ~EventQueue(); /** @todo r=andy Why not virtual? */ 99 EventQueue(void); 100 virtual ~EventQueue(void); 101 102 public: 91 103 92 104 BOOL postEvent(Event *event); 93 105 int processEventQueue(RTMSINTERVAL cMsTimeout); 94 106 int interruptEventQueueProcessing(); 95 int getSelectFD();96 static int init();97 static int uninit();98 static EventQueue *getMainEventQueue();99 100 #ifdef VBOX_WITH_XPCOM101 already_AddRefed<nsIEventQueue> getIEventQueue()102 {103 return mEventQ.get();104 }105 #else106 static int dispatchMessageOnWindows(MSG const *pMsg, int rc);107 #endif108 107 109 108 private: 110 static EventQueue *sMainQueue;111 109 112 #ifndef VBOX_WITH_XPCOM 113 114 /** The thread which the queue belongs to. */ 115 DWORD mThreadId; 116 /** Duplicated thread handle for MsgWaitForMultipleObjects. */ 117 HANDLE mhThread; 118 119 #else // VBOX_WITH_XPCOM 120 121 /** Whether it was created (and thus needs destroying) or if a queue already 122 * associated with the thread was used. */ 123 bool mEQCreated; 124 125 /** Whether event processing should be interrupted. */ 126 bool mInterrupted; 127 128 nsCOMPtr <nsIEventQueue> mEventQ; 129 nsCOMPtr <nsIEventQueueService> mEventQService; 130 131 static void *PR_CALLBACK plEventHandler(PLEvent *self); 132 static void PR_CALLBACK plEventDestructor(PLEvent *self); 133 134 #endif // VBOX_WITH_XPCOM 110 /** Critical section for serializing access to this 111 * event queue. */ 112 RTCRITSECT mCritSect; 113 /** Event semaphore for getting notified on new 114 * events being handled. */ 115 RTSEMEVENT mSemEvent; 116 /** The actual event queue, implemented as a list. */ 117 EventQueueList mEvents; 118 /** Shutdown indicator. */ 119 bool mShutdown; 135 120 }; 136 121
Note:
See TracChangeset
for help on using the changeset viewer.