#include <TCMTLock.h>
Public Member Functions | |
LockerRef (T &critical) | |
Constructs a Locker object. | |
~LockerRef () | |
Destructs the Locker object and unlocks the critical section associated with this object. | |
Private Attributes | |
T & | m_critical |
Reference to the critical section used by this object. |
..). The class has to provide the methods Lock and UnLock
When constructing a Locker it automatically locks the critical object. This can be used when you have a methode which locks a critical object on enter and UnLocks it when leaving a method.
As an alternative to:
void Test()
{
critical.Lock();
.....
.....
.....
critical.UnLock();
}
you can use a single instance of the Locker class:
void Test()
{
TCMT::Locker<type> lock(critical);
....
....
....
}
This has the advantage that critical.UnLock() will be called automatically when an exception is thrown or the method is left.
Definition at line 95 of file TCMTLock.h.
TC::MT::LockerRef< T >::LockerRef | ( | T & | critical | ) | [inline] |
Constructs a Locker object.
The critical object is automatically locked.
critical | The reference of the object locked by this constructor. |
Definition at line 104 of file TCMTLock.h.
References TC::MT::LockerRef< T >::m_critical.
TC::MT::LockerRef< T >::~LockerRef | ( | ) | [inline] |
Destructs the Locker object and unlocks the critical section associated with this object.
Definition at line 114 of file TCMTLock.h.
References TC::MT::LockerRef< T >::m_critical.
T& TC::MT::LockerRef< T >::m_critical [private] |
Reference to the critical section used by this object.
Definition at line 121 of file TCMTLock.h.
Referenced by TC::MT::LockerRef< T >::LockerRef(), and TC::MT::LockerRef< T >::~LockerRef().