#include <fxmitmutex.hh>
Public Types | |
| enum | locktype { rdlock = 0, wrlock = 1 } |
| type of lock More... | |
Public Member Functions | |
| semlock (abstractsemaphore &sem) | |
| semlock (abstractsemaphore &sem, locktype lck) | |
| virtual | ~semlock () |
{verbatim} Example:
mutex mux; void foobar () { mutexlock lockit (mux); statements of foobar here } {verbatim}
Since an object is automatically destroyed at the end of its context, semlock can also be used in loops and branches of conditional statments, or in any compound statement to protect a resource for the duration of the context.
brief Class to automatically lock and unlock a mutex.
| framexmit::semlock::semlock | ( | abstractsemaphore & | sem | ) | [inline, explicit] |
Constructs a semmutex object and locks the semaphore. brief Default constructor.
| sem | reference to a semaphore to be locked |
| framexmit::semlock::semlock | ( | abstractsemaphore & | sem, | |
| locktype | lck | |||
| ) | [inline] |
Constructs a semmutex object and locks the semaphore. The second argument specifies whether a read or write lock is applied. brief Default constructor.
| sem | reference to a semaphore to be locked | |
| lck | Lock type. |
| virtual framexmit::semlock::~semlock | ( | ) | [virtual] |
Destructs the semmutex object and unlocks the semaphore. brief Default destructor.
1.5.4