VirtualBox

Changeset 24100 in vbox for trunk/src


Ignore:
Timestamp:
Oct 27, 2009 12:02:12 AM (15 years ago)
Author:
vboxsync
Message:

iprt/req.h: Added RTReqIsBusy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/req.cpp

    r21337 r24100  
    6666
    6767    int rc = RTSemEventCreate(&(*ppQueue)->EventSem);
    68     if (rc != VINF_SUCCESS)
     68    if (RT_SUCCESS(rc))
    6969        RTMemFree(*ppQueue);
    7070
     
    8686     */
    8787    if (!pQueue)
    88     {
    89         AssertFailed();
    90         return VERR_INVALID_PARAMETER;
    91     }
     88        return VINF_SUCCESS;
     89    AssertPtr(pQueue);
    9290    RTSemEventDestroy(pQueue->EventSem);
     91    pQueue->EventSem = NIL_RTSEMEVENT;
    9392    RTMemFree(pQueue);
    9493    return VINF_SUCCESS;
    9594}
    9695RT_EXPORT_SYMBOL(RTReqDestroyQueue);
     96
    9797
    9898/**
     
    133133        if (!pReqs)
    134134        {
    135             /** @note We currently don't care if the entire time wasted here is larger than cMillies */
     135            ASMAtomicWriteBool(&pQueue->fBusy, false); /* this aint 100% perfect, but it's good enough for now... */
     136            /** @todo We currently don't care if the entire time wasted here is larger than
     137             *        cMillies */
    136138            rc = RTSemEventWait(pQueue->EventSem, cMillies);
    137139            if (rc != VINF_SUCCESS)
     
    139141            continue;
    140142        }
     143        ASMAtomicWriteBool(&pQueue->fBusy, true);
    141144
    142145        /*
     
    677680        pNext = pQueue->pReqs;
    678681        pReq->pNext = pNext;
     682        ASMAtomicWriteBool(&pQueue->fBusy, true);
    679683    } while (!ASMAtomicCmpXchgPtr((void * volatile *)&pQueue->pReqs, (void *)pReq, (void *)pNext));
    680684
     
    902906}
    903907
     908
     909/**
     910 * Checks if the queue is busy or not.
     911 *
     912 * The caller is responsible for dealing with any concurrent submitts.
     913 *
     914 * @returns true if busy, false if idle.
     915 * @param   pQueue              The queue.
     916 */
     917RTDECL(bool) RTReqIsBusy(PRTREQQUEUE pQueue)
     918{
     919    AssertPtrReturn(pQueue, false);
     920
     921    if (ASMAtomicReadBool(&pQueue->fBusy))
     922        return true;
     923    if (ASMAtomicReadPtr((void * volatile *)&pQueue->pReqs) != NULL)
     924        return true;
     925    if (ASMAtomicReadBool(&pQueue->fBusy))
     926        return true;
     927    return false;
     928}
     929RT_EXPORT_SYMBOL(RTReqIsBusy);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette