Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

void util::AutoWriteLockBase::leave (  ) 

Causes the current thread to completely release the write lock to make the managed semaphore immediately available for locking by other threads.

This implies that all nested write locks on the semaphore will be released, even those that were acquired through the calls to lock() methods of all other AutoWriteLock/AutoReadLock instances managing the same read/write semaphore.

After calling this method, the only method you are allowed to call is enter(). It will acquire the write lock again and restore the same level of nesting as it had before calling leave().

If this instance is destroyed without calling enter(), the destructor will try to restore the write lock level that existed when leave() was called minus the number of nested lock() calls made on this instance itself. This is done to preserve lock levels of other AutoWriteLock/AutoReadLock instances managing the same semaphore (if any). Tiis also means that the destructor may indefinitely block if a write or a read lock is owned by some other thread by that time.

Definition at line 577 of file AutoLock.cpp.

References AssertMsg, callUnlockImpl(), and util::LockHandle::writeLockLevel().

Referenced by VirtualBoxBase::addCaller(), Console::captureUSBDevices(), Console::detachAllUSBDevices(), Console::doCPUAdd(), Medium::LockRead(), Medium::LockWrite(), Name(), Medium::queryInfo(), Console::Reset(), SessionMachine::restoreSnapshotHandler(), Progress::WaitForCompletion(), CombinedProgress::WaitForCompletion(), CombinedProgress::WaitForOperationCompletion(), Progress::WaitForOperationCompletion(), and AutoInitSpan::~AutoInitSpan().

    AssertMsg(m->fIsLocked, ("m->fIsLocked is false, cannot leave()!"));

    // unlock in reverse order!
    uint32_t i = m->aHandles.size();
    for (HandlesVector::reverse_iterator it = m->aHandles.rbegin();
         it != m->aHandles.rend();
        --i;            // array index is zero based, decrement with every loop since we iterate backwards
        LockHandle *pHandle = *it;
        if (pHandle)
            AssertMsg(m->acUnlockedInLeave[i] == 0, ("m->cUnlockedInLeave[%d] is %d, must be 0! Called leave() twice?", i, m->acUnlockedInLeave[i]));
            m->acUnlockedInLeave[i] = pHandle->writeLockLevel();
            AssertMsg(m->acUnlockedInLeave[i] >= 1, ("m->cUnlockedInLeave[%d] is %d, must be >=1!", i, m->acUnlockedInLeave[i]));

            for (uint32_t left = m->acUnlockedInLeave[i];

Generated by  Doxygen 1.6.0   Back to index