Changeset 75539 in vbox for trunk/src/VBox/Main/include
- Timestamp:
- Nov 17, 2018 2:35:23 AM (6 years ago)
- Location:
- trunk/src/VBox/Main/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/HGCMObjects.h
r75535 r75539 40 40 } HGCMOBJ_TYPE; 41 41 42 class HGCMObject 42 43 /** 44 * A referenced object. 45 */ 46 class HGCMReferencedObject 47 { 48 private: 49 int32_t volatile m_cRefs; 50 HGCMOBJ_TYPE m_enmObjType; 51 52 protected: 53 virtual ~HGCMReferencedObject() 54 {} 55 56 public: 57 HGCMReferencedObject(HGCMOBJ_TYPE enmObjType) 58 : m_cRefs(0) 59 , m_enmObjType(enmObjType) 60 {} 61 62 void Reference() 63 { 64 int32_t cRefs = ASMAtomicIncS32(&m_cRefs); 65 NOREF(cRefs); 66 Log(("Reference: cRefs = %d\n", cRefs)); 67 } 68 69 void Dereference() 70 { 71 int32_t cRefs = ASMAtomicDecS32(&m_cRefs); 72 Log(("Dereference: cRefs = %d\n", cRefs)); 73 AssertRelease(cRefs >= 0); 74 75 if (cRefs) 76 { /* likely */ } 77 else 78 delete this; 79 } 80 81 HGCMOBJ_TYPE Type() 82 { 83 return m_enmObjType; 84 } 85 }; 86 87 88 class HGCMObject : public HGCMReferencedObject 43 89 { 44 90 private: 45 91 friend uint32_t hgcmObjMake(HGCMObject *pObject, uint32_t u32HandleIn); 46 47 int32_t volatile m_cRefs;48 HGCMOBJ_TYPE m_enmObjType;49 92 50 93 ObjectAVLCore m_core; … … 56 99 public: 57 100 HGCMObject(HGCMOBJ_TYPE enmObjType) 58 : m_cRefs(0) 59 { 60 this->m_enmObjType = enmObjType; 61 } 62 63 void Reference() 64 { 65 int32_t refCnt = ASMAtomicIncS32(&m_cRefs); 66 NOREF(refCnt); 67 Log(("Reference: refCnt = %d\n", refCnt)); 68 } 69 70 void Dereference() 71 { 72 int32_t refCnt = ASMAtomicDecS32(&m_cRefs); 73 74 Log(("Dereference: refCnt = %d\n", refCnt)); 75 76 AssertRelease(refCnt >= 0); 77 78 if (refCnt) 79 { 80 return; 81 } 82 83 delete this; 84 } 101 : HGCMReferencedObject(enmObjType) 102 {} 85 103 86 104 uint32_t Handle() … … 88 106 return (uint32_t)m_core.AvlCore.Key; 89 107 } 90 91 HGCMOBJ_TYPE Type()92 {93 return m_enmObjType;94 }95 108 }; 96 109 97 int hgcmObjInit(); 110 int hgcmObjInit(); 111 void hgcmObjUninit(); 98 112 99 void hgcmObjUninit(); 113 uint32_t hgcmObjGenerateHandle(HGCMObject *pObject); 114 uint32_t hgcmObjAssignHandle(HGCMObject *pObject, uint32_t u32Handle); 100 115 101 uint32_t hgcmObjGenerateHandle(HGCMObject *pObject); 102 uint32_t hgcmObjAssignHandle(HGCMObject *pObject, uint32_t u32Handle); 103 104 void hgcmObjDeleteHandle(uint32_t handle); 116 void hgcmObjDeleteHandle(uint32_t handle); 105 117 106 118 HGCMObject *hgcmObjReference(uint32_t handle, HGCMOBJ_TYPE enmObjType); 119 void hgcmObjDereference(HGCMReferencedObject *pObject); 107 120 108 void hgcmObjDereference(HGCMObject *pObject); 121 uint32_t hgcmObjQueryHandleCount(); 122 void hgcmObjSetHandleCount(uint32_t u32HandleCount); 109 123 110 uint32_t hgcmObjQueryHandleCount();111 void hgcmObjSetHandleCount(uint32_t u32HandleCount);112 124 113 125 #endif /* !___HGCMOBJECTS__H */ -
trunk/src/VBox/Main/include/HGCMThread.h
r75503 r75539 23 23 #include "HGCMObjects.h" 24 24 25 /* Forward declaration of the worker thread class. */ 26 class HGCMThread; 27 25 28 /** A handle for HGCM message. */ 26 29 typedef uint32_t HGCMMSGHANDLE; 27 30 28 31 /** A handle for HGCM worker threads. */ 29 typedef uint32_tHGCMTHREADHANDLE;32 typedef class HGCMThread *HGCMTHREADHANDLE; 30 33 31 34 /* Forward declaration of message core class. */ … … 45 48 * @param pMsgCore Pointer to just processed message. 46 49 */ 47 typedef DECLCALLBACK(void) HGCMMSGCALLBACK 50 typedef DECLCALLBACK(void) HGCMMSGCALLBACK(int32_t result, HGCMMsgCore *pMsgCore); 48 51 typedef HGCMMSGCALLBACK *PHGCMMSGCALLBACK; 49 52 50 /* Forward declaration of the worker thread class. */51 class HGCMThread;52 53 53 54 /** HGCM core message. */ 54 class HGCMMsgCore : public HGCMObject55 class HGCMMsgCore : public HGCMObject 55 56 { 56 57 private: … … 71 72 /** Next element in a message queue. */ 72 73 HGCMMsgCore *m_pNext; 73 /** @todo seems not necessary. Previous element in a message queue. */ 74 /** Previous element in a message queue. 75 * @todo seems not necessary. */ 74 76 HGCMMsgCore *m_pPrev; 75 77 … … 80 82 int32_t m_rcSend; 81 83 82 void InitializeCore (uint32_t u32MsgId, HGCMTHREADHANDLE hThread);84 void InitializeCore(uint32_t u32MsgId, HGCMThread * pThread); 83 85 84 86 protected: 85 virtual ~HGCMMsgCore 87 virtual ~HGCMMsgCore(); 86 88 87 89 public: 88 HGCMMsgCore 89 90 uint32_t MsgId 91 92 HGCMThread *Thread 90 HGCMMsgCore() : HGCMObject(HGCMOBJ_MSG) {}; 91 92 uint32_t MsgId(void) { return m_u32Msg; }; 93 94 HGCMThread *Thread(void) { return m_pThread; }; 93 95 94 96 /** Initialize message after it was allocated. */ 95 virtual void Initialize 97 virtual void Initialize(void) {}; 96 98 97 99 /** Uninitialize message. */ 98 virtual void Uninitialize 100 virtual void Uninitialize(void) {}; 99 101 100 102 }; … … 103 105 /** HGCM worker thread function. 104 106 * 105 * @param ThreadHandle Handle of the thread.107 * @param pThread The HGCM thread instance. 106 108 * @param pvUser User specified thread parameter. 107 109 */ 108 typedef DECLCALLBACK(void) FNHGCMTHREAD (HGCMTHREADHANDLE ThreadHandle, void *pvUser);110 typedef DECLCALLBACK(void) FNHGCMTHREAD(HGCMThread *pThread, void *pvUser); 109 111 typedef FNHGCMTHREAD *PFNHGCMTHREAD; 110 112 … … 119 121 * @return VBox error code 120 122 */ 121 int hgcmThreadInit 122 void hgcmThreadUninit 123 int hgcmThreadInit(void); 124 void hgcmThreadUninit(void); 123 125 124 126 125 127 /** Create a HGCM worker thread. 126 128 * 127 * @param p Handle Where to store the returned worker thread handle.129 * @param ppThread Where to return the pointer to the worker thread. 128 130 * @param pszThreadName Name of the thread, needed by runtime. 129 131 * @param pfnThread The worker thread function. … … 137 139 * @return VBox error code 138 140 */ 139 int hgcmThreadCreate (HGCMTHREADHANDLE *pHandle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,140 141 int hgcmThreadCreate(HGCMThread **ppThread, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser, 142 const char *pszStatsSubDir, PUVM pUVM); 141 143 142 144 /** Wait for termination of a HGCM worker thread. 143 145 * 144 * @param handle The HGCM thread handle. 145 * 146 * @return VBox error code 147 */ 148 int hgcmThreadWait (HGCMTHREADHANDLE handle); 146 * @param pThread The HGCM thread. The passed in reference is always 147 * consumed. 148 * 149 * @return VBox error code 150 */ 151 int hgcmThreadWait(HGCMThread *pThread); 149 152 150 153 /** Allocate a message to be posted to HGCM worker thread. 151 154 * 152 * @param hThread Worker thread handle.155 * @param pThread The HGCM worker thread. 153 156 * @param pHandle Where to store the returned message handle. 154 157 * @param u32MsgId Message identifier. … … 157 160 * @return VBox error code 158 161 */ 159 int hgcmMsgAlloc (HGCMTHREADHANDLE hThread, HGCMMSGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage);162 int hgcmMsgAlloc(HGCMThread *pThread, HGCMMSGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage); 160 163 161 164 /** Post a message to HGCM worker thread. … … 166 169 * @return VBox error code 167 170 */ 168 int hgcmMsgPost 171 int hgcmMsgPost(HGCMMSGHANDLE hMsg, PHGCMMSGCALLBACK pfnCallback); 169 172 170 173 /** Send a message to HGCM worker thread. … … 175 178 * @return VBox error code 176 179 */ 177 int hgcmMsgSend 180 int hgcmMsgSend(HGCMMSGHANDLE hMsg); 178 181 179 182 180 183 /* Wait for and get a message. 181 184 * 182 * @param hThread The thread handle.185 * @param pThread The HGCM worker thread. 183 186 * @param ppMsg Where to store returned message pointer. 184 187 * … … 187 190 * @thread worker thread 188 191 */ 189 int hgcmMsgGet (HGCMTHREADHANDLE hThread, HGCMMsgCore **ppMsg);192 int hgcmMsgGet(HGCMThread *pThread, HGCMMsgCore **ppMsg); 190 193 191 194 … … 199 202 * @thread worker thread 200 203 */ 201 void hgcmMsgComplete 204 void hgcmMsgComplete(HGCMMsgCore *pMsg, int32_t result); 202 205 203 206
Note:
See TracChangeset
for help on using the changeset viewer.