本文整理汇总了C++中RTSemEventCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ RTSemEventCreate函数的具体用法?C++ RTSemEventCreate怎么用?C++ RTSemEventCreate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTSemEventCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mVirtualBox
VirtualBox::ClientWatcher::ClientWatcher(const ComObjPtr<VirtualBox> &pVirtualBox) :
mVirtualBox(pVirtualBox),
mThread(NIL_RTTHREAD),
mUpdateReq(CWUPDATEREQARG),
mLock(LOCKCLASS_OBJECTSTATE)
{
#if defined(RT_OS_WINDOWS)
mUpdateReq = ::CreateEvent(NULL, FALSE, FALSE, NULL);
#elif defined(RT_OS_OS2)
RTSemEventCreate(&mUpdateReq);
#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) || defined(VBOX_WITH_GENERIC_SESSION_WATCHER)
RTSemEventCreate(&mUpdateReq);
/* start with high timeouts, nothing to do */
ASMAtomicUoWriteU8(&mUpdateAdaptCtr, 0);
#else
# error "Port me!"
#endif
int vrc = RTThreadCreate(&mThread,
worker,
(void *)this,
0,
RTTHREADTYPE_MAIN_WORKER,
RTTHREADFLAGS_WAITABLE,
"Watcher");
AssertRC(vrc);
}
示例2: unconst
/**
* Initializes the object (called right after construction).
*
* @returns VBox status code.
*/
int USBProxyBackendSolaris::init(USBProxyService *aUsbProxyService, const com::Utf8Str &strId, const com::Utf8Str &strAddress)
{
USBProxyBackend::init(aUsbProxyService, strId, strAddress);
unconst(m_strBackend) = Utf8Str("host");
/*
* Create semaphore.
*/
int rc = RTSemEventCreate(&mNotifyEventSem);
if (RT_FAILURE(rc))
return rc;
/*
* Initialize the USB library.
*/
rc = USBLibInit();
if (RT_FAILURE(rc))
{
/* mNotifyEventSem will be destroyed in uninit */
return rc;
}
mUSBLibInitialized = true;
/*
* Start the poller thread.
*/
start();
return VINF_SUCCESS;
}
示例3: RTSemEventCreate
/**
* Initializes the object (called right after construction).
*
* @returns S_OK on success and non-fatal failures, some COM error otherwise.
*/
HRESULT USBProxyServiceSolaris::init(void)
{
/*
* Create semaphore.
*/
int rc = RTSemEventCreate(&mNotifyEventSem);
if (RT_FAILURE(rc))
{
mLastError = rc;
return E_FAIL;
}
/*
* Initialize the USB library.
*/
rc = USBLibInit();
if (RT_FAILURE(rc))
{
mLastError = rc;
return S_OK;
}
mUSBLibInitialized = true;
/*
* Start the poller thread.
*/
start();
return S_OK;
}
示例4: RTSemEventCreate
/**
* Initializes the object (called right after construction).
*
* @returns VBox status code.
*/
int USBProxyBackendSolaris::init(void)
{
/*
* Create semaphore.
*/
int rc = RTSemEventCreate(&mNotifyEventSem);
if (RT_FAILURE(rc))
return rc;
/*
* Initialize the USB library.
*/
rc = USBLibInit();
if (RT_FAILURE(rc))
{
RTSemEventDestroy(mNotifyEventSem);
return rc;
}
mUSBLibInitialized = true;
/*
* Start the poller thread.
*/
start();
return VINF_SUCCESS;
}
示例5: SUPDECL
SUPDECL(int) SUPSemEventCreate(PSUPDRVSESSION pSession, PSUPSEMEVENT phEvent)
{
int rc;
RTSEMEVENT hEventReal;
/*
* Input validation.
*/
AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER);
AssertPtrReturn(phEvent, VERR_INVALID_POINTER);
/*
* Create the event semaphore object.
*/
rc = RTSemEventCreate(&hEventReal);
if (RT_SUCCESS(rc))
{
void *pvObj = SUPR0ObjRegister(pSession, SUPDRVOBJTYPE_SEM_EVENT, supR0SemEventDestructor, hEventReal, NULL);
if (pvObj)
{
uint32_t h32;
rc = RTHandleTableAllocWithCtx(pSession->hHandleTable, pvObj, SUPDRV_HANDLE_CTX_EVENT, &h32);
if (RT_SUCCESS(rc))
{
*phEvent = (SUPSEMEVENT)(uintptr_t)h32;
return VINF_SUCCESS;
}
SUPR0ObjRelease(pvObj, pSession);
}
else
RTSemEventDestroy(hEventReal);
}
return rc;
}
示例6: DECLHIDDEN
/**
* Allocate a new request from the heap.
*
* @returns IPRT status code.
* @param enmType The reques type.
* @param fPoolOrQueue The owner type.
* @param pvOwner The owner.
* @param phReq Where to return the request handle.
*/
DECLHIDDEN(int) rtReqAlloc(RTREQTYPE enmType, bool fPoolOrQueue, void *pvOwner, PRTREQ *phReq)
{
PRTREQ pReq = (PRTREQ)RTMemAllocZ(sizeof(*pReq));
if (RT_UNLIKELY(!pReq))
return VERR_NO_MEMORY;
/*
* Create the semaphore used for waiting.
*/
int rc = RTSemEventCreate(&pReq->EventSem);
AssertRCReturnStmt(rc, RTMemFree(pReq), rc);
/*
* Initialize the packet and return it.
*/
pReq->u32Magic = RTREQ_MAGIC;
pReq->fEventSemClear = true;
pReq->fSignalPushBack = true;
pReq->fPoolOrQueue = fPoolOrQueue;
pReq->iStatusX = VERR_RT_REQUEST_STATUS_STILL_PENDING;
pReq->enmState = RTREQSTATE_ALLOCATED;
pReq->pNext = NULL;
pReq->uOwner.pv = pvOwner;
pReq->fFlags = RTREQFLAGS_IPRT_STATUS;
pReq->enmType = enmType;
pReq->cRefs = 1;
*phReq = pReq;
return VINF_SUCCESS;
}
示例7: RT_ZERO
HRESULT HostDnsServiceDarwin::init()
{
SCDynamicStoreContext ctx;
RT_ZERO(ctx);
ctx.info = this;
m->m_store = SCDynamicStoreCreate(NULL, CFSTR("org.virtualbox.VBoxSVC"),
(SCDynamicStoreCallBack)HostDnsServiceDarwin::hostDnsServiceStoreCallback,
&ctx);
AssertReturn(m->m_store, E_FAIL);
m->m_DnsWatcher = SCDynamicStoreCreateRunLoopSource(NULL, m->m_store, 0);
if (!m->m_DnsWatcher)
return E_OUTOFMEMORY;
int rc = RTSemEventCreate(&m->m_evtStop);
AssertRCReturn(rc, E_FAIL);
CFRunLoopSourceContext sctx;
RT_ZERO(sctx);
sctx.perform = HostDnsServiceDarwin::Data::performShutdownCallback;
m->m_Stopper = CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &sctx);
AssertReturn(m->m_Stopper, E_FAIL);
HRESULT hrc = HostDnsMonitor::init();
AssertComRCReturn(hrc, hrc);
return updateInfo();
}
示例8: RTDECL
RTDECL(int) RTFileAioCtxCreate(PRTFILEAIOCTX phAioCtx, uint32_t cAioReqsMax,
uint32_t fFlags)
{
PRTFILEAIOCTXINTERNAL pCtxInt;
unsigned cReqsWaitMax;
AssertPtrReturn(phAioCtx, VERR_INVALID_POINTER);
AssertReturn(!(fFlags & ~RTFILEAIOCTX_FLAGS_VALID_MASK), VERR_INVALID_PARAMETER);
if (cAioReqsMax == RTFILEAIO_UNLIMITED_REQS)
return VERR_OUT_OF_RANGE;
cReqsWaitMax = RT_MIN(cAioReqsMax, AIO_LISTIO_MAX);
pCtxInt = (PRTFILEAIOCTXINTERNAL)RTMemAllocZ( sizeof(RTFILEAIOCTXINTERNAL)
+ cReqsWaitMax * sizeof(PRTFILEAIOREQINTERNAL));
if (RT_UNLIKELY(!pCtxInt))
return VERR_NO_MEMORY;
/* Create event semaphore. */
int rc = RTSemEventCreate(&pCtxInt->SemEventCancel);
if (RT_FAILURE(rc))
{
RTMemFree(pCtxInt);
return rc;
}
pCtxInt->u32Magic = RTFILEAIOCTX_MAGIC;
pCtxInt->cMaxRequests = cAioReqsMax;
pCtxInt->cReqsWaitMax = cReqsWaitMax;
pCtxInt->fFlags = fFlags;
*phAioCtx = (RTFILEAIOCTX)pCtxInt;
return VINF_SUCCESS;
}
示例9: main
int main( int argc, char **argv)
{
int rc = VINF_SUCCESS;
char ach[2];
RTR3InitExe(argc, &argv, 0);
RTPrintf("VirtualBox guest additions X11 seamless mode testcase\n");
if (0 == XInitThreads())
{
RTPrintf("Failed to initialise X11 threading, exiting.\n");
exit(1);
}
/* Set an X11 error handler, so that we don't die when we get unavoidable errors. */
XSetErrorHandler(vboxClientXLibErrorHandler);
RTPrintf("\nPress <Enter> to exit...\n");
RTSemEventCreate(&eventSem);
/** Our instance of the seamless class. */
VBoxGuestSeamless seamless;
LogRel(("Starting seamless Guest Additions...\n"));
rc = seamless.init();
if (rc != VINF_SUCCESS)
{
RTPrintf("Failed to initialise seamless Additions, rc = %d\n", rc);
}
RTStrmGetLine(g_pStdIn, ach, sizeof(ach));
seamless.uninit();
return rc;
}
示例10: RTDECL
/**
* Init a Ping-Pong construct.
*
* @returns iprt status code.
* @param pPP Pointer to the ping-pong structure which needs initialization.
*/
RTDECL(int) RTSemPingPongInit(PRTPINGPONG pPP)
{
/*
* Init the structure.
*/
pPP->enmSpeaker = RTPINGPONGSPEAKER_PING;
int rc = RTSemEventCreate(&pPP->Ping);
if (RT_SUCCESS(rc))
{
rc = RTSemEventCreate(&pPP->Pong);
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
RTSemEventDestroy(pPP->Ping);
}
return rc;
}
示例11: mVirtualBox
VirtualBox::ClientWatcher::ClientWatcher(const ComObjPtr<VirtualBox> &pVirtualBox) :
mVirtualBox(pVirtualBox),
mThread(NIL_RTTHREAD),
mUpdateReq(CWUPDATEREQARG),
mLock(LOCKCLASS_OBJECTSTATE)
{
#if defined(RT_OS_WINDOWS)
/* Misc state. */
mfTerminate = false;
mcMsWait = INFINITE;
mcActiveSubworkers = 0;
/* Update request. The UpdateReq event is also used to wake up subthreads. */
mfUpdateReq = false;
mUpdateReq = ::CreateEvent(NULL /*pSecAttr*/, TRUE /*fManualReset*/, FALSE /*fInitialState*/, NULL /*pszName*/);
AssertRelease(mUpdateReq != NULL);
/* Initialize the handle array. */
for (uint32_t i = 0; i < RT_ELEMENTS(mahWaitHandles); i++)
mahWaitHandles[i] = NULL;
for (uint32_t i = 0; i < RT_ELEMENTS(mahWaitHandles); i += CW_MAX_HANDLES_PER_THREAD)
mahWaitHandles[i] = mUpdateReq;
mcWaitHandles = 1;
#elif defined(RT_OS_OS2)
RTSemEventCreate(&mUpdateReq);
#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) || defined(VBOX_WITH_GENERIC_SESSION_WATCHER)
RTSemEventCreate(&mUpdateReq);
/* start with high timeouts, nothing to do */
ASMAtomicUoWriteU8(&mUpdateAdaptCtr, 0);
#else
# error "Port me!"
#endif
int vrc = RTThreadCreate(&mThread,
worker,
(void *)this,
0,
RTTHREADTYPE_MAIN_WORKER,
RTTHREADFLAGS_WAITABLE,
"Watcher");
AssertRC(vrc);
}
示例12: RTSemEventCreate
int GuestDnDCallbackEvent::Reset(void)
{
int rc = VINF_SUCCESS;
if (NIL_RTSEMEVENT == mSemEvent)
rc = RTSemEventCreate(&mSemEvent);
mRc = VINF_SUCCESS;
return rc;
}
示例13: m_EventSem
GuestDnDResponse::GuestDnDResponse(const ComObjPtr<Guest>& pGuest)
: m_EventSem(NIL_RTSEMEVENT)
, m_defAction(0)
, m_allActions(0)
, m_parent(pGuest)
{
int rc = RTSemEventCreate(&m_EventSem);
if (RT_FAILURE(rc))
throw rc;
}
示例14: mUserCnt
EventQueue::EventQueue(void)
: mUserCnt(0),
mShutdown(false)
{
int rc = RTCritSectInit(&mCritSect);
AssertRC(rc);
rc = RTSemEventCreate(&mSemEvent);
AssertRC(rc);
}
示例15: mRefCount
VBoxDnDDropTarget::VBoxDnDDropTarget(VBoxDnDWnd *pParent)
: mRefCount(1),
mpWndParent(pParent),
mdwCurEffect(0),
mpvData(NULL),
mcbData(0),
hEventDrop(NIL_RTSEMEVENT)
{
int rc = RTSemEventCreate(&hEventDrop);
LogFlowFunc(("rc=%Rrc\n", rc)); NOREF(rc);
}