ACS::ThreadSyncGuard

NAME
SYNOPSIS
Detailed Description
Constructor & Destructor Documentation
Member Function Documentation
Member Data Documentation
Author

NAME

ACS::ThreadSyncGuard −

Class implementing scope locking synchronization pattern.

SYNOPSIS

#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

Detailed Description

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.
ThreadSyncGuard
uses recursive thread mutex. An example of usage:

      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
      }

Constructor & Destructor Documentation

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
block
if true, lock is acuired, otherwise not

ACS::ThreadSyncGuard::~ThreadSyncGuard () Destructor. Relases mutex if necessary.

Member Function Documentation

void ACS::ThreadSyncGuard::acquire () Blocks the thread until the lock is acquired.

void ACS::ThreadSyncGuard::release () Releases the lock.

Member Data Documentation

bool ACS::ThreadSyncGuard::acquired_m

state of mutex

ACE_Recursive_Thread_Mutex* ACS::ThreadSyncGuard::mutex_mp

mutex used by guard

Author

Generated automatically by Doxygen for ACS-2015.2 C++ API from the source code.