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. | |
Protected Member Functions | |
| Guard (const Guard &) | |
| Copy constructor. | |
| Guard & | operator= (const Guard &) |
| Assignment operator. | |
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.
Definition at line 67 of file B2BITS_Guard.h.
| Utils::Guard< T >::Guard | ( | T & | lock ) | [inline] |
Constructor.
Acquires the given resource.
| lock | Resource monitor implementation |
Definition at line 72 of file B2BITS_Guard.h.
| Utils::Guard< T >::~Guard | ( | ) | [inline] |
Destructor.
Releases the given resource.
Definition at line 77 of file B2BITS_Guard.h.
References Utils::Guard< T >::release().
| Utils::Guard< T >::Guard | ( | const Guard< T > & | ) | [protected] |
Copy constructor.
| Guard& Utils::Guard< T >::operator= | ( | const Guard< T > & | ) | [protected] |
Assignment operator.
| void Utils::Guard< T >::release | ( | ) | [inline] |
Releases the resource.
Definition at line 84 of file B2BITS_Guard.h.
Referenced by Utils::Guard< T >::~Guard().
1.7.2