Changeset 77079 in vbox for trunk/src/VBox
- Timestamp:
- Jan 31, 2019 4:05:05 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128532
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r76958 r77079 1066 1066 public: 1067 1067 1068 GuestWaitEvent(uint32_t uCID); 1069 GuestWaitEvent(uint32_t uCID, const GuestEventTypes &lstEvents); 1068 GuestWaitEvent(void); 1070 1069 virtual ~GuestWaitEvent(void); 1071 1070 1072 1071 public: 1073 1072 1073 int Init(uint32_t uCID); 1074 int Init(uint32_t uCID, const GuestEventTypes &lstEvents); 1074 1075 int Cancel(void); 1075 1076 const ComPtr<IEvent> Event(void) { return mEvent; } … … 1079 1080 const GuestEventTypes &Types(void) { return mEventTypes; } 1080 1081 size_t TypeCount(void) { return mEventTypes.size(); } 1081 1082 protected:1083 1084 int Init(uint32_t uCID);1085 1082 1086 1083 protected: -
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r76958 r77079 939 939 AssertRCReturn(rc, rc); 940 940 941 #if 1 /** @todo r=bird: Incorrect exception and memory handling, no strategy for dealing with duplicate IDs: */ 942 rc = RTCritSectEnter(&mWaitEventCritSect); 943 if (RT_SUCCESS(rc)) 944 { 945 try 946 { 947 GuestWaitEvent *pEvent = new GuestWaitEvent(idContext, lstEvents); 948 AssertPtr(pEvent); 949 950 LogFlowThisFunc(("New event=%p, CID=%RU32\n", pEvent, idContext)); 951 952 /* Insert event into matching event group. This is for faster per-group 953 * lookup of all events later. */ 954 for (GuestEventTypes::const_iterator itEvents = lstEvents.begin(); 955 itEvents != lstEvents.end(); ++itEvents) 956 { 957 /* Check if the event group already has an event with the same 958 * context ID in it (collision). */ 959 GuestWaitEvents eventGroup = mWaitEventGroups[(*itEvents)]; /** @todo r=bird: Why copy it? */ 960 if (eventGroup.find(idContext) == eventGroup.end()) 961 { 962 /* No, insert. */ 963 mWaitEventGroups[(*itEvents)].insert(std::pair<uint32_t, GuestWaitEvent *>(idContext, pEvent)); 964 } 965 else 966 { 967 rc = VERR_ALREADY_EXISTS; 968 break; 969 } 970 } 971 972 if (RT_SUCCESS(rc)) 973 { 974 /* Register event in regular event list. */ 975 if (mWaitEvents.find(idContext) == mWaitEvents.end()) 976 { 977 mWaitEvents[idContext] = pEvent; 978 } 979 else 980 rc = VERR_ALREADY_EXISTS; 981 } 982 983 if (RT_SUCCESS(rc)) 984 *ppEvent = pEvent; 985 } 986 catch(std::bad_alloc &) 987 { 988 rc = VERR_NO_MEMORY; 989 } 990 991 int rc2 = RTCritSectLeave(&mWaitEventCritSect); 992 if (RT_SUCCESS(rc)) 993 rc = rc2; 994 } 995 return rc; 996 997 #else /** @todo r=bird: Version with proper exception handling, no leaks and limited duplicate CID handling: */ 998 999 GuestWaitEvent *pEvent = new GuestWaitEvent(idContext, lstEvents); 1000 AssertReturn(pEvent, VERR_NO_MEMORY); 941 GuestWaitEvent *pEvent = new GuestWaitEvent(); 942 AssertPtrReturn(pEvent, VERR_NO_MEMORY); 943 944 rc = pEvent->Init(idContext, lstEvents); 945 AssertRCReturn(rc, rc); 946 1001 947 LogFlowThisFunc(("New event=%p, CID=%RU32\n", pEvent, idContext)); 1002 948 … … 1055 1001 { 1056 1002 Assert(cInserts > 0); 1057 NOREF(cInserts);1003 RT_NOREF(cInserts); 1058 1004 1059 1005 /* … … 1080 1026 delete pEvent; 1081 1027 return rc; 1082 #endif1083 1028 } 1084 1029 … … 1528 1473 } 1529 1474 1530 GuestWaitEvent::GuestWaitEvent(uint32_t uCID, 1531 const GuestEventTypes &lstEvents) 1532 { 1533 int rc2 = Init(uCID); 1534 AssertRC(rc2); /** @todo Throw exception here. */ /** @todo r=bird: add+use Init() instead. Will cause weird VERR_CANCELLED errors in GuestBase::signalWaitEvent. */ 1535 1536 mEventTypes = lstEvents; 1537 } 1538 1539 GuestWaitEvent::GuestWaitEvent(uint32_t uCID) 1540 { 1541 int rc2 = Init(uCID); 1542 AssertRC(rc2); /** @todo Throw exception here. */ /** @todo r=bird: add+use Init() instead. Will cause weird VERR_CANCELLED errors in GuestBase::signalWaitEvent. */ 1475 GuestWaitEvent::GuestWaitEvent(void) 1476 { 1543 1477 } 1544 1478 … … 1562 1496 } 1563 1497 1498 /** 1499 * Initializes a wait event with a given context ID (CID). 1500 * 1501 * @returns IPRT status code. 1502 * @param uCID Context ID to initialize wait event with. 1503 */ 1564 1504 int GuestWaitEvent::Init(uint32_t uCID) 1565 1505 { 1566 1506 return GuestWaitEventBase::Init(uCID); 1507 } 1508 1509 /** 1510 * Initializes a wait event with a given context ID (CID) and a list of event types to wait for. 1511 * 1512 * @returns IPRT status code. 1513 * @param uCID Context ID to initialize wait event with. 1514 * @param lstEvent List of event types to wait for this wait event to get signalled. 1515 */ 1516 int GuestWaitEvent::Init(uint32_t uCID, const GuestEventTypes &lstEvents) 1517 { 1518 int rc = GuestWaitEventBase::Init(uCID); 1519 if (RT_SUCCESS(rc)) 1520 { 1521 mEventTypes = lstEvents; 1522 } 1523 1524 return rc; 1567 1525 } 1568 1526
Note:
See TracChangeset
for help on using the changeset viewer.