VirtualBox

Changeset 75660 in vbox for trunk/src/VBox/Main/src-all


Ignore:
Timestamp:
Nov 22, 2018 12:20:52 PM (6 years ago)
Author:
vboxsync
Message:

Main/AutoCaller: add a "try lock" option to AutoUninitSpan, for situations where the uninit should fail when there are still callers active.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/AutoCaller.cpp

    r69500 r75660  
    313313}
    314314
    315 ObjectState::State ObjectState::autoUninitSpanConstructor()
     315ObjectState::State ObjectState::autoUninitSpanConstructor(bool fTry)
    316316{
    317317    AutoWriteLock stateLock(mStateLock COMMA_LOCKVAL_SRC_POS);
     
    330330         * returns, the object state is well-defined (NotReady). */
    331331
     332        if (fTry)
     333            return Ready;
     334
    332335        /* lazy semaphore creation */
    333336        if (mInitUninitSem == NIL_RTSEMEVENTMULTI)
     
    361364    if (mCallers > 0)
    362365    {
     366        if (fTry)
     367            return Ready;
     368
    363369        /* lazy creation */
    364370        Assert(mZeroCallersSem == NIL_RTSEMEVENT);
     
    518524 * @param aObj  |this| pointer of the VirtualBoxBase object whose uninit()
    519525 *              method is being called.
    520  */
    521 AutoUninitSpan::AutoUninitSpan(VirtualBoxBase *aObj)
     526 * @param fTry  @c true if the wait for other callers should be skipped,
     527 *              requiring checking if the uninit span is actually operational.
     528 */
     529AutoUninitSpan::AutoUninitSpan(VirtualBoxBase *aObj, bool fTry /* = false */)
    522530    : mObj(aObj),
    523531      mInitFailed(false),
    524       mUninitDone(false)
     532      mUninitDone(false),
     533      mUninitFailed(false)
    525534{
    526535    Assert(mObj);
    527536    ObjectState::State state;
    528     state = mObj->getObjectState().autoUninitSpanConstructor();
     537    state = mObj->getObjectState().autoUninitSpanConstructor(fTry);
    529538    if (state == ObjectState::InitFailed)
    530539        mInitFailed = true;
    531540    else if (state == ObjectState::NotReady)
    532541        mUninitDone = true;
     542    else if (state == ObjectState::Ready)
     543        mUninitFailed = true;
    533544}
    534545
     
    539550{
    540551    /* do nothing if already uninitialized */
    541     if (mUninitDone)
     552    if (mUninitDone || mUninitFailed)
    542553        return;
    543554
     
    553564{
    554565    /* do nothing if already uninitialized */
    555     if (mUninitDone)
     566    if (mUninitDone || mUninitFailed)
    556567        return;
    557568
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