|
ACS::ThreadSyncGuard − Class implementing scope locking synchronization pattern. |
|
#include <acsThreadBase.h> |
|
Public Member Functions |
|
ThreadSyncGuard (ACE_Recursive_Thread_Mutex *mutex, bool block=true) |
|
~ThreadSyncGuard () |
|
void acquire () |
|
void release () |
|
Public Attributes |
|
ACE_Recursive_Thread_Mutex * mutex_mp |
|
mutex used by guard |
|
bool acquired_m |
|
state of mutex |
|
Class implementing scope locking synchronization pattern. ThreadSyncGuard implements scope locking
synchronization pattern, which is very usefull not to forget
to release (or relase can be by-passed by an exception) and
so avoiding deadlocks. Mutex is automatically released when
out of scope. void PowerSupplyImpl::shutdown()
{
|
|
//ThreadSyncGuard guard(’gizmo0::propertyVector’); |
|||
|
ThreadSyncGuard guard(mutex_m); |
|||
// do something |
|||
// optional lock release |
|||
| guard.release(); | |||
// do something |
|||
// optional locking |
|||
| guard.acquire(); | |||
// do something |
|||
// lock is automatically released when out of scope |
} |
|
ACS::ThreadSyncGuard::ThreadSyncGuard (ACE_Recursive_Thread_Mutex * mutex, bool block = true) Constructor. Creates a guard and acquires mutex if <block> is true. |
|
Parameters: |
|
mutex mutex to be used by guard |
|
ACS::ThreadSyncGuard::~ThreadSyncGuard () Destructor. Relases mutex if necessary. |
|
void ACS::ThreadSyncGuard::acquire () Blocks the thread until the lock is acquired. |
|
void ACS::ThreadSyncGuard::release () Releases the lock. |
|
bool ACS::ThreadSyncGuard::acquired_m |
|
state of mutex |
|
ACE_Recursive_Thread_Mutex* ACS::ThreadSyncGuard::mutex_mp |
|
mutex used by guard |
|
Generated automatically by Doxygen for ACS-2014.6 C++ API from the source code. |