Added missing launcher
[mupen64plus-pandora.git] / source / rice_gles / 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 //*SEB*, single process, no lock needed...
26 #define NOLOCK
27
28 class CCritSect
29 {
30 public:
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
67 protected:
68 #ifndef NOLOCK
69     SDL_mutex *cs;
70 #endif
71     int locked;
72 };
73
74 #endif // !defined(CRITSECT_H)
75