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

VirtualBoxBaseProto::AutoUninitSpan Class Reference

#include <VirtualBoxBase.h>

List of all members.

Detailed Description

Smart class to enclose the state transition Ready->InUnnit->NotReady, InitFailed->InUnnit->NotReady or WillUninit->InUnnit->NotReady.

The purpose of this span is to protect object uninitialization.

Instances must be created as a stack-based variable taking |this| pointer as the argument at the beginning of uninit() methods of VirtualBoxBase subclasses. When this variable is created it automatically places the object to the InUninit state, unless it is already in the NotReady state as indicated by uninitDone() returning |true|. In the latter case, the uninit() method must immediately return because there should be nothing to uninitialize.

When this variable goes out of scope (i.e. gets destroyed), it places the object to NotReady state.

A typical usage pattern is: void Component::uninit() { AutoUninitSpan autoUninitSpan (this); if (autoUninitSpan.uninitDone()) return; ... }

The constructor of this class blocks the current thread execution until the number of callers added to the object using addCaller() or AutoCaller drops to zero. For this reason, it is forbidden to create instances of this class (or call uninit()) within the AutoCaller or addCaller() scope because it is a guaranteed deadlock.

Never create instances of this class outside uninit() methods and never pass anything other than |this| as the argument to the constructor!

Definition at line 1049 of file VirtualBoxBase.h.

Public Member Functions

 AutoUninitSpan (VirtualBoxBaseProto *aObj)
bool initFailed ()
bool uninitDone ()
 ~AutoUninitSpan ()

Private Attributes

bool mInitFailed: 1
bool mUninitDone: 1

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index