ZenLib
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
ZenLib
CriticalSection.h
Go to the documentation of this file.
1
// ZenLib::CriticalSection - CriticalSection functions
2
// Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
3
//
4
// This software is provided 'as-is', without any express or implied
5
// warranty. In no event will the authors be held liable for any damages
6
// arising from the use of this software.
7
//
8
// Permission is granted to anyone to use this software for any purpose,
9
// including commercial applications, and to alter it and redistribute it
10
// freely, subject to the following restrictions:
11
//
12
// 1. The origin of this software must not be misrepresented; you must not
13
// claim that you wrote the original software. If you use this software
14
// in a product, an acknowledgment in the product documentation would be
15
// appreciated but is not required.
16
// 2. Altered source versions must be plainly marked as such, and must not be
17
// misrepresented as being the original software.
18
// 3. This notice may not be removed or altered from any source distribution.
19
//
20
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22
//
23
// CriticalSection functions
24
//
25
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26
27
//---------------------------------------------------------------------------
28
#ifndef ZenLib_CriticalSectionH
29
#define ZenLib_CriticalSectionH
30
//---------------------------------------------------------------------------
31
32
//---------------------------------------------------------------------------
33
#ifdef CS
34
#undef CS //Solaris defines this somewhere
35
#endif
36
//---------------------------------------------------------------------------
37
38
namespace
ZenLib
39
{
40
41
//***************************************************************************
42
/// @brief CriticalSection manipulation
43
//***************************************************************************
44
45
class
CriticalSection
46
{
47
public
:
48
//Constructor/Destructor
49
CriticalSection
();
50
~CriticalSection
();
51
52
//Enter/Leave
53
void
Enter
();
54
void
Leave
();
55
56
private
:
57
void
* CritSect;
58
};
59
60
//***************************************************************************
61
/// @brief CriticalSectionLocker helper
62
//***************************************************************************
63
64
class
CriticalSectionLocker
65
{
66
public
:
67
CriticalSectionLocker
(
ZenLib::CriticalSection
&CS)
68
{
69
CritSec=&CS;
70
CritSec->
Enter
();
71
}
72
73
~CriticalSectionLocker
()
74
{
75
CritSec->
Leave
();
76
}
77
78
private
:
79
ZenLib::CriticalSection
*CritSec;
80
};
81
82
}
//NameSpace
83
84
#endif
Generated on Wed Mar 12 2014 22:02:19 for ZenLib by
1.8.1.2