Rice GLES2 (from mupen64plus-ae) plugin. Compile but doesn't works well on the OpenPa...
[mupen64plus-pandora.git] / source / gles2rice / src / CritSect.h
1 /*
2 Copyright (C) 2003 Rice1964
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, 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 class CCritSect
26 {
27 public:
28     CCritSect()
29     {
30         cs = SDL_CreateMutex();
31         locked = 0;
32     }
33
34     ~CCritSect()
35     {
36         SDL_DestroyMutex(cs);
37     }
38
39     void Lock()
40     {
41         SDL_LockMutex(cs);
42         locked = 1;
43     }
44
45     void Unlock()
46     {
47         locked = 0;
48         SDL_UnlockMutex(cs);
49     }
50
51     bool IsLocked()
52     {
53         return (locked != 0);
54     }
55
56 protected:
57     SDL_mutex *cs;
58     int locked;
59 };
60
61 #endif // !defined(CRITSECT_H)
62