VirtualBox

Ignore:
Timestamp:
Jan 18, 2010 10:07:28 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56726
Message:

RTSemRWIsReadOwner: For assertion in main.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/semrw-generic.cpp

    r25831 r25908  
    869869RTDECL(bool) RTSemRWIsWriteOwner(RTSEMRW hRWSem)
    870870{
     871    /*
     872     * Validate handle.
     873     */
    871874    struct RTSEMRWINTERNAL *pThis = hRWSem;
    872 
    873     /*
    874      * Validate handle.
    875      */
    876875    AssertPtrReturn(pThis, false);
    877876    AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false);
     
    886885}
    887886RT_EXPORT_SYMBOL(RTSemRWIsWriteOwner);
     887
     888
     889RTDECL(bool)  RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear)
     890{
     891    /*
     892     * Validate handle.
     893     */
     894    struct RTSEMRWINTERNAL *pThis = hRWSem;
     895    AssertPtrReturn(pThis, false);
     896    AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false);
     897
     898    /*
     899     * Check write ownership.  The writer is also a valid reader.
     900     */
     901    RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
     902    RTNATIVETHREAD hWriter;
     903    ASMAtomicUoReadHandle(&pThis->hWriter, &hWriter);
     904    if (hWriter == hNativeSelf)
     905        return true;
     906    if (hWriter != NIL_RTNATIVETHREAD)
     907        return false;
     908
     909#ifdef RTSEMRW_STRICT
     910    /*
     911     * Ask the lock validator.
     912     */
     913    return RTLockValidatorRecSharedIsOwner(&pThis->ValidatorRead, NIL_RTTHREAD);
     914#else
     915    /*
     916     * If there are no reads we cannot be one of them... But if there are we
     917     * cannot know and can only return what the caller want to hear.
     918     */
     919    if (pThis->cReads == 0)
     920        return false;
     921    return fWannaHear;
     922#endif
     923}
     924RT_EXPORT_SYMBOL(RTSemRWIsReadOwner);
    888925
    889926
Note: See TracChangeset for help on using the changeset viewer.

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