#include <Mutex.h>
Public Member Functions | |
CritSec () | |
~CritSec () |
A 'critical section' class that provides a somewhat more convenient interface to the Mutex class. A CritSec object simply locks the global Mutex upon creation and unlocks it on destruction.
Therefore, this means that rather than write:
{ TSE3::Impl::Mutex::mutex()->lock(); // do something TSE3::Impl::Mutex::mutex()->unlock(); }You can simply write:
{ TSE3::Impl::CritSec cs; // do something }Clearly, this prevents a possible source of error, where you might forget to unlock the mutex after having locked it. It is also in most cases a lot more convenient to use.
The CritSec class is small, simple and implemented with inline functions so the resultant generated code for both of the above examples is identical.
|
|
|
|