ZenLib
CriticalSection.h
Go to the documentation of this file.
1 /* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2  *
3  * Use of this source code is governed by a zlib-style license that can
4  * be found in the License.txt file in the root of the source tree.
5  */
6 
7 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 //
9 // CriticalSection functions
10 //
11 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 
13 //---------------------------------------------------------------------------
14 #ifndef ZenLib_CriticalSectionH
15 #define ZenLib_CriticalSectionH
16 //---------------------------------------------------------------------------
17 
18 //---------------------------------------------------------------------------
19 #ifdef CS
20  #undef CS //Solaris defines this somewhere
21 #endif
22 //---------------------------------------------------------------------------
23 
24 namespace ZenLib
25 {
26 
27 //***************************************************************************
28 /// @brief CriticalSection manipulation
29 //***************************************************************************
30 
32 {
33 public :
34  //Constructor/Destructor
37 
38  //Enter/Leave
39  void Enter();
40  void Leave();
41 
42 private :
43  void* CritSect;
44 };
45 
46 //***************************************************************************
47 /// @brief CriticalSectionLocker helper
48 //***************************************************************************
49 
51 {
52 public:
54  {
55  CritSec=&CS;
56  CritSec->Enter();
57  }
58 
60  {
61  CritSec->Leave();
62  }
63 
64 private:
65  ZenLib::CriticalSection *CritSec;
66 };
67 
68 } //NameSpace
69 
70 #endif
CriticalSectionLocker helper.
Definition: CriticalSection.h:51
~CriticalSectionLocker()
Definition: CriticalSection.h:59
CriticalSectionLocker(ZenLib::CriticalSection &CS)
Definition: CriticalSection.h:53
CriticalSection manipulation.
Definition: CriticalSection.h:32
Definition: BitStream.h:24