HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_LockScopeType< Lock > Class Template Reference

#include <UT_LockUtil.h>

+ Inheritance diagram for UT_LockScopeType< Lock >:

Public Member Functions

 UT_LockScopeType ()
 Default constructor with mutex lock. Use acquire() to give it mutex. More...
 
 UT_LockScopeType (Lock &mutex, bool acquire=true)
 Construct with given mutex. Acquires it by default. More...
 
 UT_LockScopeType (UT_LockScopeType< Lock > &&scope)
 
 ~UT_LockScopeType ()
 
void lock ()
 Lock the mutex. More...
 
void lock (Lock &mutex)
 
bool tryLock ()
 Try to lock the mutex, return immediately false if someone else owns it. More...
 
bool tryLock (Lock &mutex)
 
bool safeLock (Lock &mutex)
 
void unlock ()
 Unlock the mutex before this object is deleted. More...
 

Detailed Description

template<class Lock>
class UT_LockScopeType< Lock >

Like UT_AutoLockType except it supports explicit control of when to lock (or unlock) while providing exception safety.

Note
This is similar to hboost::unique_lock
The same UT_LockScopeType object cannot be safely accessed from multiple threads!
Examples:
packedshareddata/GU_PackedSharedData.C.

Definition at line 46 of file UT_LockUtil.h.

Constructor & Destructor Documentation

template<class Lock >
UT_LockScopeType< Lock >::UT_LockScopeType ( )
inline

Default constructor with mutex lock. Use acquire() to give it mutex.

Definition at line 50 of file UT_LockUtil.h.

template<class Lock >
UT_LockScopeType< Lock >::UT_LockScopeType ( Lock mutex,
bool  acquire = true 
)
inline

Construct with given mutex. Acquires it by default.

Definition at line 56 of file UT_LockUtil.h.

template<class Lock >
UT_LockScopeType< Lock >::UT_LockScopeType ( UT_LockScopeType< Lock > &&  scope)
inline

Definition at line 63 of file UT_LockUtil.h.

template<class Lock >
UT_LockScopeType< Lock >::~UT_LockScopeType ( )
inline

Definition at line 70 of file UT_LockUtil.h.

Member Function Documentation

template<class Lock >
void UT_LockScopeType< Lock >::lock ( )
inline

Lock the mutex.

Definition at line 77 of file UT_LockUtil.h.

template<class Lock >
void UT_LockScopeType< Lock >::lock ( Lock mutex)
inline

Assign a new mutex reference and lock it

Note
Unlocks the old mutex.

Definition at line 90 of file UT_LockUtil.h.

template<class Lock >
bool UT_LockScopeType< Lock >::safeLock ( Lock mutex)
inline

Lock the mutex, return false if a dead lock was detected.

Note
Only works if the underlying mutex supports it.

Definition at line 124 of file UT_LockUtil.h.

template<class Lock >
bool UT_LockScopeType< Lock >::tryLock ( )
inline

Try to lock the mutex, return immediately false if someone else owns it.

Definition at line 100 of file UT_LockUtil.h.

template<class Lock >
bool UT_LockScopeType< Lock >::tryLock ( Lock mutex)
inline

Try to lock the mutex, return immediately false if someone else owns it.

Note
Unlocks the old mutex.

Definition at line 113 of file UT_LockUtil.h.

template<class Lock >
void UT_LockScopeType< Lock >::unlock ( )
inline

Unlock the mutex before this object is deleted.

Definition at line 138 of file UT_LockUtil.h.


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