B2BITS FIX Antenna C++ 2.32.1
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Utils::Guard< T > Class Template Reference

This template class employs a C++ idiom (described by Bjarne Stroustrup) that uses the constructor to acquire a resource automatically when an object of the class is created and uses the destructor to release the resource automatically when it goes out of scope. More...

#include <B2BITS_Guard.h>

Public Member Functions

 Guard (T &lock)
 Constructor.
 
void release ()
 Releases the resource.
 
 ~Guard ()
 Destructor.
 

Detailed Description

template<class T>
class Utils::Guard< T >

This template class employs a C++ idiom (described by Bjarne Stroustrup) that uses the constructor to acquire a resource automatically when an object of the class is created and uses the destructor to release the resource automatically when it goes out of scope.

Since Guard is parameterized by the type of lock (such as Mutex), this class can be used with a fam-ily of synchronization wrappers that conform to a uniform interface. E.g.: Guard<Mutex> guard (lock_); // guard constructor acquires m_lock.

Constructor & Destructor Documentation

◆ Guard()

template<class T >
Utils::Guard< T >::Guard ( T & lock)
inline

Constructor.

Acquires the given resource.

Parameters
lockResource monitor implementation

◆ ~Guard()

template<class T >
Utils::Guard< T >::~Guard ( )
inline

Destructor.

Releases the given resource.

References Utils::Guard< T >::release().

Member Function Documentation

◆ release()

template<class T >
void Utils::Guard< T >::release ( )
inline

Releases the resource.

Referenced by Utils::Guard< T >::~Guard().