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

RWLockHandle * VirtualBoxBaseProto::lockHandle (  )  const [virtual, inherited]

Returns a pointer to a LockHandle used by AutoWriteLock/AutoReadLock for locking. Subclasses are allowed to return NULL -- in this case, the AutoWriteLock/AutoReadLock object constructed using an instance of such subclass will simply turn into no-op.

Implements util::Lockable.

Reimplemented in SessionMachine, and SnapshotMachine.

Definition at line 69 of file VirtualBoxBase.cpp.

References AssertCompile, VirtualBoxBaseProto::mObjectLock, NULL, and RT_UNLIKELY.

{
    /* lazy initialization */
    if (RT_UNLIKELY(!mObjectLock))
    {
        AssertCompile (sizeof (RWLockHandle *) == sizeof (void *));
        RWLockHandle *objLock = new RWLockHandle;
        if (!ASMAtomicCmpXchgPtr ((void * volatile *) &mObjectLock, objLock, NULL))
        {
            delete objLock;
            objLock = (RWLockHandle *) ASMAtomicReadPtr ((void * volatile *) &mObjectLock);
        }
        return objLock;
    }
    return mObjectLock;
}


Generated by  Doxygen 1.6.0   Back to index