Merge branch 'master' of git@github.com:xbmc/xbmc
[vuplus_xbmc] / xbmc / threads / CriticalSection.h
1 //////////////////////////////////////////////////////////////////////
2 //
3 // CriticalSection.h: interface for the CCriticalSection class.
4 //
5 //////////////////////////////////////////////////////////////////////
6 #ifndef _CRITICAL_SECTION_H_
7 #define _CRITICAL_SECTION_H_
8
9 #if _MSC_VER > 1000
10 #pragma once
11 #endif // _MSC_VER > 1000
12 #ifdef _LINUX
13 #include "PlatformDefs.h"
14 #include "linux/XSyncUtils.h"
15 #include "XCriticalSection.h"
16 #else
17 #include "win32/XCriticalSection.h"
18 #endif
19
20 /*
21  *      Copyright (C) 2005-2008 Team XBMC
22  *      http://www.xbmc.org
23  *
24  *  This Program is free software; you can redistribute it and/or modify
25  *  it under the terms of the GNU General Public License as published by
26  *  the Free Software Foundation; either version 2, or (at your option)
27  *  any later version.
28  *
29  *  This Program is distributed in the hope that it will be useful,
30  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
31  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32  *  GNU General Public License for more details.
33  *
34  *  You should have received a copy of the GNU General Public License
35  *  along with XBMC; see the file COPYING.  If not, write to
36  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
37  *  http://www.gnu.org/copyleft/gpl.html
38  *
39  */
40
41 class CCriticalSection
42 {
43 public:
44   // Constructor/destructor.
45   CCriticalSection();
46   virtual ~CCriticalSection();
47
48   XCriticalSection& getCriticalSection() { return m_criticalSection; }
49
50 private:
51   XCriticalSection m_criticalSection;
52
53   //don't allow copying a CCriticalSection
54   CCriticalSection(const CCriticalSection& section) {}
55   CCriticalSection& operator=(const CCriticalSection& section) {return *this;}
56 };
57
58 // The CCritical section overloads.
59 void InitializeCriticalSection(CCriticalSection* section);
60 void DeleteCriticalSection(CCriticalSection* section);
61 BOOL OwningCriticalSection(CCriticalSection* section);
62 DWORD ExitCriticalSection(CCriticalSection* section);
63 void RestoreCriticalSection(CCriticalSection* section, DWORD count);
64 void EnterCriticalSection(CCriticalSection* section);
65 void LeaveCriticalSection(CCriticalSection* section);
66
67 // And a few special ones.
68 void EnterCriticalSection(CCriticalSection& section);
69 void LeaveCriticalSection(CCriticalSection& section);
70 BOOL OwningCriticalSection(CCriticalSection& section);
71 DWORD ExitCriticalSection(CCriticalSection& section);
72 void RestoreCriticalSection(CCriticalSection& section, DWORD count);
73
74 #endif