1 /***************************************************************************
2 * Copyright (C) 2009 by Stefan Fuhrmann *
3 * stefanfuhrmann@alice-dsl.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
27 * Just a simple critical section (i.e. recursive mutex)
28 * implementation with minimal overhead.
31 class CCriticalSection
35 /// OS-specific critical section object
37 CRITICAL_SECTION section
;
43 CCriticalSection(void);
47 ~CCriticalSection(void);
49 /// Acquire the mutex, i.e. enter the critical section
53 /// Release the mutex, i.e. leave the critical section
58 // Mutex functionality
60 __forceinline
void CCriticalSection::Acquire()
62 EnterCriticalSection (§ion
);
65 __forceinline
void CCriticalSection::Release()
67 LeaveCriticalSection (§ion
);
71 * RAII lock class for \ref CCriticalSection mutexes.
74 class CCriticalSectionLock
78 CCriticalSection
& section
;
80 // dummy assignement operator to silence the C4512 compiler warning
81 // not implemented assigment operator (even is dummy and private) to
82 // get rid of cppcheck error as well as accidental use
83 CCriticalSectionLock
& operator=( const CCriticalSectionLock
& ) /*{ section = ; return * this; }*/;
86 __forceinline
CCriticalSectionLock (CCriticalSection
& section
)
92 __forceinline
~CCriticalSectionLock()