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

#include <UT_LockUtil.h>

Public Member Functions

 UT_UniqueLock ()=delete
 
 UT_UniqueLock (UT_EmptyScope)
 Construct without mutex. Use acquire() to give it a mutex. More...
 
 UT_UniqueLock (Lock &mutex, bool acquire=true)
 Construct with given mutex. Acquires it by default. More...
 
 UT_UniqueLock (UT_UniqueLock< Lock > &&scope)
 
 ~UT_UniqueLock ()
 
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_UniqueLock< Lock >

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

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

Definition at line 51 of file UT_LockUtil.h.

Constructor & Destructor Documentation

template<class Lock >
UT_UniqueLock< Lock >::UT_UniqueLock ( )
delete
template<class Lock >
UT_UniqueLock< Lock >::UT_UniqueLock ( UT_EmptyScope  )
inlineexplicit

Construct without mutex. Use acquire() to give it a mutex.

Definition at line 57 of file UT_LockUtil.h.

template<class Lock >
UT_UniqueLock< Lock >::UT_UniqueLock ( Lock mutex,
bool  acquire = true 
)
inlineexplicit

Construct with given mutex. Acquires it by default.

Definition at line 64 of file UT_LockUtil.h.

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

Definition at line 71 of file UT_LockUtil.h.

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

Definition at line 78 of file UT_LockUtil.h.

Member Function Documentation

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

Lock the mutex.

Definition at line 87 of file UT_LockUtil.h.

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

Assign a new mutex reference and lock it

Note
Unlocks the old mutex.

Definition at line 100 of file UT_LockUtil.h.

template<class Lock >
bool UT_UniqueLock< 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 134 of file UT_LockUtil.h.

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

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

Definition at line 110 of file UT_LockUtil.h.

template<class Lock >
bool UT_UniqueLock< 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 123 of file UT_LockUtil.h.

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

Unlock the mutex before this object is deleted.

Definition at line 148 of file UT_LockUtil.h.


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