VirtualBox

Changeset 82874 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 27, 2020 1:11:48 PM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/common: Added ShClEventRetain() and ShClEventRelease().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r82871 r82874  
    347347    LogFlowFuncLeaveRC(rc);
    348348    return rc;
     349}
     350
     351/**
     352 * Retains an event by increasing its reference count.
     353 *
     354 * @returns New reference count, or UINT32_MAX if failed.
     355 * @param   pSource             Event source of event to retain.
     356 * @param   idEvent             ID of event to retain.
     357 */
     358uint32_t ShClEventRetain(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent)
     359{
     360    PSHCLEVENT pEvent = shclEventGet(pSource, idEvent);
     361    if (!pEvent)
     362    {
     363        AssertFailed();
     364        return UINT32_MAX;
     365    }
     366
     367    AssertReturn(pEvent->cRefs < 64, UINT32_MAX); /* Sanity. Yeah, not atomic. */
     368
     369    return ASMAtomicIncU32(&pEvent->cRefs);
     370}
     371
     372/**
     373 * Releases an event by decreasing its reference count.
     374 *
     375 * @returns New reference count, or UINT32_MAX if failed.
     376 * @param   pSource             Event source of event to release.
     377 * @param   idEvent             ID of event to release.
     378 */
     379uint32_t ShClEventRelease(PSHCLEVENTSOURCE pSource, SHCLEVENTID idEvent)
     380{
     381    PSHCLEVENT pEvent = shclEventGet(pSource, idEvent);
     382    if (!pEvent)
     383    {
     384        AssertFailed();
     385        return UINT32_MAX;
     386    }
     387
     388    AssertReturn(pEvent->cRefs, UINT32_MAX); /* Sanity. Yeah, not atomic. */
     389
     390    return ASMAtomicDecU32(&pEvent->cRefs);
    349391}
    350392
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