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

util::AutoMultiLock2 Class Reference

#include <AutoLock.h>

Inheritance diagram for util::AutoMultiLock2:

util::AutoMultiLockBase< 2 >

List of all members.

Detailed Description

AutoMultiLock for 2 locks.

The AutoMultiLockN family of classes provides a possibility to manage several read/write semaphores at once. This is handy if all managed semaphores need to be locked and unlocked synchronously and will also help to avoid locking order errors.

Instances of AutoMultiLockN classes are constructed from a list of LockOps arguments. The AutoMultiLockBase::lock() method will make sure that the given list of semaphores represented by LockOps pointers will be locked in order they are passed to the constructor. The AutoMultiLockBase::unlock() method will make sure that they will be unlocked in reverse order.

The type of the lock to request is specified for each semaphore individually using the corresponding LockOps getter of a LockHandle or Lockable object: LockHandle::wlock() in order to request a write lock or LockHandle::rlock() in order to request a read lock.

Here is a typical usage pattern: ... LockHandle data1, data2; ... { AutoMultiLock2 multiLock (data1.wlock(), data2.rlock()); // both locks are held here:

Definition at line 1155 of file AutoLock.h.

Public Member Functions

 AutoMultiLock2 (A(0), A(1))
void lock ()
void unlock ()

Protected Attributes

bool mIsLocked
LockOpsmOps [Cnt]

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

Generated by  Doxygen 1.6.0   Back to index