本文整理汇总了C++中GuestWaitEvent类的典型用法代码示例。如果您正苦于以下问题:C++ GuestWaitEvent类的具体用法?C++ GuestWaitEvent怎么用?C++ GuestWaitEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GuestWaitEvent类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AssertPtrReturn
int GuestFile::i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS,
void *pvData, uint32_t cbData, uint32_t *pcbWritten)
{
AssertPtrReturn(pvData, VERR_INVALID_POINTER);
AssertReturn(cbData, VERR_INVALID_PARAMETER);
LogFlowThisFunc(("uOffset=%RU64, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n",
uOffset, uTimeoutMS, pvData, cbData));
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
eventTypes.push_back(VBoxEventType_OnGuestFileWrite);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[8];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setUInt32(mData.mID /* File handle */);
paParms[i++].setUInt64(uOffset /* Offset where to starting writing */);
paParms[i++].setUInt32(cbData /* Size (in bytes) to write */);
paParms[i++].setPointer(pvData, cbData);
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_WRITE_AT, i, paParms);
if (RT_SUCCESS(vrc))
{
uint32_t cbWritten = 0;
vrc = i_waitForWrite(pEvent, uTimeoutMS, &cbWritten);
if (RT_SUCCESS(vrc))
{
LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten));
if (cbWritten)
*pcbWritten = cbWritten;
}
}
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例2: LogFlowThisFuncEnter
int GuestFile::openFile(uint32_t uTimeoutMS, int *pGuestRc)
{
LogFlowThisFuncEnter();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
LogFlowThisFunc(("strFile=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%RU32, uOffset=%RU64\n",
mData.mOpenInfo.mFileName.c_str(), mData.mOpenInfo.mOpenMode.c_str(),
mData.mOpenInfo.mDisposition.c_str(), mData.mOpenInfo.mCreationMode, mData.mOpenInfo.mInitialOffset));
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[8];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(),
(ULONG)mData.mOpenInfo.mFileName.length() + 1);
paParms[i++].setPointer((void*)mData.mOpenInfo.mOpenMode.c_str(),
(ULONG)mData.mOpenInfo.mOpenMode.length() + 1);
paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(),
(ULONG)mData.mOpenInfo.mDisposition.length() + 1);
paParms[i++].setPointer((void*)mData.mOpenInfo.mSharingMode.c_str(),
(ULONG)mData.mOpenInfo.mSharingMode.length() + 1);
paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode);
paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset);
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_OPEN, i, paParms);
if (RT_SUCCESS(vrc))
vrc = waitForStatusChange(pEvent, uTimeoutMS,
NULL /* FileStatus */, pGuestRc);
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例3: LogFlowThisFuncEnter
int GuestFile::i_openFile(uint32_t uTimeoutMS, int *pGuestRc)
{
LogFlowThisFuncEnter();
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
LogFlowThisFunc(("strFile=%s, enmAccessMode=%d (%s) enmOpenAction=%d (%s) uCreationMode=%RU32, mfOpenEx=%RU32\n",
mData.mOpenInfo.mFileName.c_str(), mData.mOpenInfo.mAccessMode, mData.mOpenInfo.mpszAccessMode,
mData.mOpenInfo.mOpenAction, mData.mOpenInfo.mpszOpenAction, mData.mOpenInfo.mCreationMode,
mData.mOpenInfo.mfOpenEx));
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[8];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(),
(ULONG)mData.mOpenInfo.mFileName.length() + 1);
paParms[i++].setString(mData.mOpenInfo.mpszAccessMode);
paParms[i++].setString(mData.mOpenInfo.mpszOpenAction);
paParms[i++].setString(""); /** @todo sharing mode. */
paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode);
paParms[i++].setUInt64(0 /* initial offset */);
/** @todo Next protocol version: add flags, replace strings, remove initial offset. */
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_OPEN, i, paParms);
if (RT_SUCCESS(vrc))
vrc = i_waitForStatusChange(pEvent, uTimeoutMS,
NULL /* FileStatus */, pGuestRc);
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例4: LogFlowThisFunc
int GuestFile::i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType,
uint32_t uTimeoutMS, uint64_t *puOffset)
{
LogFlowThisFunc(("iOffset=%RI64, uTimeoutMS=%RU32\n",
iOffset, uTimeoutMS));
AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
int vrc;
GuestWaitEvent *pEvent = NULL;
GuestEventTypes eventTypes;
try
{
eventTypes.push_back(VBoxEventType_OnGuestFileStateChanged);
eventTypes.push_back(VBoxEventType_OnGuestFileOffsetChanged);
vrc = registerWaitEvent(eventTypes, &pEvent);
}
catch (std::bad_alloc)
{
vrc = VERR_NO_MEMORY;
}
if (RT_FAILURE(vrc))
return vrc;
/* Prepare HGCM call. */
VBOXHGCMSVCPARM paParms[4];
int i = 0;
paParms[i++].setUInt32(pEvent->ContextID());
paParms[i++].setUInt32(mData.mID /* File handle */);
paParms[i++].setUInt32(eSeekType /* Seek method */);
/** @todo uint64_t vs. int64_t! */
paParms[i++].setUInt64((uint64_t)iOffset /* Offset (in bytes) to start reading */);
alock.release(); /* Drop write lock before sending. */
vrc = sendCommand(HOST_FILE_SEEK, i, paParms);
if (RT_SUCCESS(vrc))
vrc = i_waitForOffsetChange(pEvent, uTimeoutMS, puOffset);
unregisterWaitEvent(pEvent);
LogFlowFuncLeaveRC(vrc);
return vrc;
}
示例5: AssertPtrReturn
int GuestBase::signalWaitEventInternalEx(PVBOXGUESTCTRLHOSTCBCTX pCbCtx,
int rc, int guestRc,
const GuestWaitEventPayload *pPayload)
{
AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER);
/* pPayload is optional. */
int rc2;
GuestWaitEvents::iterator itEvent = mWaitEvents.find(pCbCtx->uContextID);
if (itEvent != mWaitEvents.end())
{
LogFlowThisFunc(("Signalling event=%p (CID %RU32, rc=%Rrc, guestRc=%Rrc, pPayload=%p) ...\n",
itEvent->second, itEvent->first, rc, guestRc, pPayload));
GuestWaitEvent *pEvent = itEvent->second;
AssertPtr(pEvent);
rc2 = pEvent->SignalInternal(rc, guestRc, pPayload);
}
else
rc2 = VERR_NOT_FOUND;
return rc2;
}
示例6: LogFlowThisFuncEnter
int GuestBase::cancelWaitEvents(void)
{
LogFlowThisFuncEnter();
int rc = RTCritSectEnter(&mWaitEventCritSect);
if (RT_SUCCESS(rc))
{
GuestEventGroup::iterator itEventGroups = mWaitEventGroups.begin();
while (itEventGroups != mWaitEventGroups.end())
{
GuestWaitEvents::iterator itEvents = itEventGroups->second.begin();
while (itEvents != itEventGroups->second.end())
{
GuestWaitEvent *pEvent = itEvents->second;
AssertPtr(pEvent);
/*
* Just cancel the event, but don't remove it from the
* wait events map. Don't delete it though, this (hopefully)
* is done by the caller using unregisterWaitEvent().
*/
int rc2 = pEvent->Cancel();
AssertRC(rc2);
itEvents++;
}
itEventGroups++;
}
int rc2 = RTCritSectLeave(&mWaitEventCritSect);
if (RT_SUCCESS(rc))
rc = rc2;
}
LogFlowFuncLeaveRC(rc);
return rc;
}