本文整理汇总了C++中ASMAtomicDecU32函数的典型用法代码示例。如果您正苦于以下问题:C++ ASMAtomicDecU32函数的具体用法?C++ ASMAtomicDecU32怎么用?C++ ASMAtomicDecU32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASMAtomicDecU32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RTDECL
RTDECL(int) RTPipeRead(RTPIPE hPipe, void *pvBuf, size_t cbToRead, size_t *pcbRead)
{
RTPIPEINTERNAL *pThis = hPipe;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTPIPE_MAGIC, VERR_INVALID_HANDLE);
AssertReturn(pThis->fRead, VERR_ACCESS_DENIED);
AssertPtr(pcbRead);
AssertPtr(pvBuf);
int rc = rtPipeTryNonBlocking(pThis);
if (RT_SUCCESS(rc))
{
ssize_t cbRead = read(pThis->fd, pvBuf, RT_MIN(cbToRead, SSIZE_MAX));
if (cbRead >= 0)
{
if (cbRead || !cbToRead || !rtPipePosixHasHup(pThis))
*pcbRead = cbRead;
else
rc = VERR_BROKEN_PIPE;
}
else if (errno == EAGAIN)
{
*pcbRead = 0;
rc = VINF_TRY_AGAIN;
}
else
rc = RTErrConvertFromErrno(errno);
ASMAtomicDecU32(&pThis->u32State);
}
return rc;
}
示例2: LogFlowThisFunc
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void VirtualBoxClient::uninit()
{
LogFlowThisFunc(("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
if (autoUninitSpan.uninitDone())
return;
if (mData.m_ThreadWatcher != NIL_RTTHREAD)
{
/* Signal the event semaphore and wait for the thread to terminate.
* if it hangs for some reason exit anyway, this can cause a crash
* though as the object will no longer be available. */
RTSemEventSignal(mData.m_SemEvWatcher);
RTThreadWait(mData.m_ThreadWatcher, 30000, NULL);
mData.m_ThreadWatcher = NIL_RTTHREAD;
RTSemEventDestroy(mData.m_SemEvWatcher);
mData.m_SemEvWatcher = NIL_RTSEMEVENT;
}
mData.m_pVirtualBox.setNull();
ASMAtomicDecU32(&g_cInstances);
}
示例3: vboxVhwaHlpCheckTerm
int vboxVhwaHlpCheckTerm(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId)
{
Assert(VidPnSourceId < (D3DDDI_VIDEO_PRESENT_SOURCE_ID)VBoxCommonFromDeviceExt(pDevExt)->cDisplays);
if (VidPnSourceId >= (D3DDDI_VIDEO_PRESENT_SOURCE_ID)VBoxCommonFromDeviceExt(pDevExt)->cDisplays)
return VERR_INVALID_PARAMETER;
PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[VidPnSourceId];
Assert(!!(pSource->Vhwa.Settings.fFlags & VBOXVHWA_F_ENABLED));
/** @todo need a better sync */
uint32_t cNew = ASMAtomicDecU32(&pSource->Vhwa.cOverlaysCreated);
int rc = VINF_SUCCESS;
if (!cNew)
{
rc = vboxVhwaHlpDestroyPrimary(pDevExt, pSource, VidPnSourceId);
AssertRC(rc);
}
else
{
Assert(cNew < UINT32_MAX / 2);
}
return rc;
}
示例4: RTDECL
RTDECL(int) RTPipeWrite(RTPIPE hPipe, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
{
RTPIPEINTERNAL *pThis = hPipe;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTPIPE_MAGIC, VERR_INVALID_HANDLE);
AssertReturn(!pThis->fRead, VERR_ACCESS_DENIED);
AssertPtr(pcbWritten);
AssertPtr(pvBuf);
int rc = rtPipeTryNonBlocking(pThis);
if (RT_SUCCESS(rc))
{
if (cbToWrite)
{
ssize_t cbWritten = write(pThis->fd, pvBuf, RT_MIN(cbToWrite, SSIZE_MAX));
if (cbWritten >= 0)
*pcbWritten = cbWritten;
else if (errno == EAGAIN)
{
*pcbWritten = 0;
rc = VINF_TRY_AGAIN;
}
else
rc = RTErrConvertFromErrno(errno);
}
else
*pcbWritten = 0;
ASMAtomicDecU32(&pThis->u32State);
}
return rc;
}
示例5: RTDECL
RTDECL(int) RTSemMutexDestroy(RTSEMMUTEX hMutexSem)
{
/*
* Validate input.
*/
PRTSEMMUTEXINTERNAL pThis = (PRTSEMMUTEXINTERNAL)hMutexSem;
if (!pThis)
return VERR_INVALID_PARAMETER;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), VERR_INVALID_HANDLE);
RT_ASSERT_INTS_ON();
/*
* Kill it, wake up all waiting threads and release the reference.
*/
AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, ~RTSEMMUTEX_MAGIC, RTSEMMUTEX_MAGIC), VERR_INVALID_HANDLE);
lck_spin_lock(pThis->pSpinlock);
if (pThis->cWaiters > 0)
thread_wakeup_prim((event_t)pThis, FALSE /* one_thread */, THREAD_RESTART);
if (ASMAtomicDecU32(&pThis->cRefs) == 0)
rtSemMutexDarwinFree(pThis);
else
lck_spin_unlock(pThis->pSpinlock);
return VINF_SUCCESS;
}
示例6: DECLINLINE
/**
* Releases a reference to a RTMPNTONSPECIFICARGS heap allocation, freeing it
* when the last reference is released.
*/
DECLINLINE(void) rtMpNtOnSpecificRelease(PRTMPNTONSPECIFICARGS pArgs)
{
uint32_t cRefs = ASMAtomicDecU32(&pArgs->cRefs);
AssertMsg(cRefs <= 1, ("cRefs=%#x\n", cRefs));
if (cRefs == 0)
ExFreePool(pArgs);
}
示例7: DECLINLINE
/**
* Release a reference, destroy the thing if necessary.
*
* @param pThis The semaphore.
*/
DECLINLINE(void) rtR0SemEventMultiHkuRelease(PRTSEMEVENTMULTIINTERNAL pThis)
{
if (RT_UNLIKELY(ASMAtomicDecU32(&pThis->cRefs) == 0))
{
Assert(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC);
RTMemFree(pThis);
}
}
示例8: i_release
uint32_t i_release()
{
uint32_t cRefs = ASMAtomicDecU32(&m_cRefs);
Assert(cRefs < _1K);
if (cRefs == 0)
delete this;
return cRefs;
}
示例9: VBoxDispVHWACommandRelease
void VBoxDispVHWACommandRelease(PVBOXDISPDEV pDev, VBOXVHWACMD* pCmd)
{
uint32_t cRefs = ASMAtomicDecU32(&pCmd->cRefs);
Assert(cRefs < UINT32_MAX / 2);
if(!cRefs)
{
VBoxDispVHWACommandFree(pDev, pCmd);
}
}
示例10: renderspuContextRelease
static uint32_t renderspuContextRelease( ContextInfo *context )
{
uint32_t cRefs = ASMAtomicDecU32(&context->cRefs);
if (!cRefs)
renderspuDestroyContextTerminate( context );
else
CRASSERT(cRefs < UINT32_MAX/2);
return cRefs;
}
示例11: vboxVhwaHlpOverlayListRemove
static void vboxVhwaHlpOverlayListRemove(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_OVERLAY pOverlay)
{
PVBOXWDDM_SOURCE pSource = &pDevExt->aSources[pOverlay->VidPnSourceId];
KIRQL OldIrql;
KeAcquireSpinLock(&pSource->OverlayListLock, &OldIrql);
ASMAtomicDecU32(&pSource->cOverlays);
RemoveEntryList(&pOverlay->ListEntry);
KeReleaseSpinLock(&pSource->OverlayListLock, OldIrql);
}
示例12: DECLINLINE
/**
* Release a reference, destroy the thing if necessary.
*
* @param pThis The semaphore.
*/
DECLINLINE(void) rtR0SemEventMultiDarwinRelease(PRTSEMEVENTMULTIINTERNAL pThis)
{
if (RT_UNLIKELY(ASMAtomicDecU32(&pThis->cRefs) == 0))
{
Assert(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC);
lck_spin_destroy(pThis->pSpinlock, g_pDarwinLockGroup);
RTMemFree(pThis);
}
}
示例13: DECLINLINE
DECLINLINE(void) vbvaVhwaCommandRelease(PVBOXMP_DEVEXT pDevExt, VBOXVHWACMD* pCmd)
{
uint32_t cRefs = ASMAtomicDecU32(&pCmd->cRefs);
Assert(cRefs < UINT32_MAX / 2);
if(!cRefs)
{
VBoxHGSMIBufferFree(&VBoxCommonFromDeviceExt(pDevExt)->guestCtx, pCmd);
}
}
示例14: DECLINLINE
DECLINLINE(VOID) vboxWddmSwapchainRelease(PVBOXWDDM_SWAPCHAIN pSwapchain)
{
const uint32_t cRefs = ASMAtomicDecU32(&pSwapchain->cRefs);
Assert(cRefs < UINT32_MAX/2);
if (!cRefs)
{
vboxWddmMemFree(pSwapchain);
}
}
示例15: rtThreadRemoveLocked
/**
* Removes the thread from the AVL tree, call owns the tree lock
* and has cleared the RTTHREADINT_FLAG_IN_TREE bit.
*
* @param pThread The thread to remove.
*/
static void rtThreadRemoveLocked(PRTTHREADINT pThread)
{
PRTTHREADINT pThread2 = (PRTTHREADINT)RTAvlPVRemove(&g_ThreadTree, pThread->Core.Key);
#if !defined(RT_OS_OS2) /** @todo this asserts for threads created by NSPR */
AssertMsg(pThread2 == pThread, ("%p(%s) != %p (%p/%s)\n", pThread2, pThread2 ? pThread2->szName : "<null>",
pThread, pThread->Core.Key, pThread->szName));
#endif
if (pThread2)
ASMAtomicDecU32(&g_cThreadInTree);
}