[0a1223]: mt / MutexGuard.h Maximize Restore History

Download this file

MutexGuard.h    57 lines (47 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/***************************************************************************
mt/MutexGuard.h - Guard class for Synchronization by Mutal Exclusion
-------------------
begin : Tue Oct 3 2000
copyright : (C) 2000 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef _MUTEX_GUARD_H_
#define _MUTEX_GUARD_H_
#include "mt/TSS_Object.h"
class Mutex;
/**
* \class MutexGuard
* Implements an easy-to-use guard class for a simple mutal
* exclusive locking for multithreaded applications. This should be used
* prior to directly using a Mutex because it also supports asynchronous
* thread exits through the TSS_Object class.
*
* \author Thomas Eschenbacher <Thomas.Eschenbacher@gmx.de>
* \data 2000-10-03
*/
class MutexGuard: public TSS_Object
{
public:
/**
* Constructor, takes a Mutex object and automatically locks it
* @param lock the mutex to be locked
*/
MutexGuard(Mutex &lock);
/**
* Destructor, automatically releases (unlocks) the lock.
*/
~MutexGuard();
private:
/** the mutex to be locked */
Mutex &m_lock;
};
#endif // _MUTEX_GUARD_H_
//***************************************************************************