Rice Video Plugin for GLES1.1
[mupen64plus-pandora.git] / source / rice_gles / src / CritSect.h
CommitLineData
d07c171f 1/*
2Copyright (C) 2003 Rice1964
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18*/
19
20#if !defined(CRITSECT_H)
21#define CRITSECT_H
22
23#include <SDL.h>
24
25//*SEB*, single process, no lock needed...
26#define NOLOCK
27
28class CCritSect
29{
30public:
31 CCritSect()
32 {
33#ifndef NOLOCK
34 cs = SDL_CreateMutex();
35#endif
36 locked = 0;
37 }
38
39 ~CCritSect()
40 {
41#ifndef NOLOCK
42 SDL_DestroyMutex(cs);
43#endif
44 }
45
46 void Lock()
47 {
48#ifndef NOLOCK
49 SDL_LockMutex(cs);
50#endif
51 locked = 1;
52 }
53
54 void Unlock()
55 {
56 locked = 0;
57#ifndef NOLOCK
58 SDL_UnlockMutex(cs);
59#endif
60 }
61
62 bool IsLocked()
63 {
64 return (locked != 0);
65 }
66
67protected:
68#ifndef NOLOCK
69 SDL_mutex *cs;
70#endif
71 int locked;
72};
73
74#endif // !defined(CRITSECT_H)
75