~ubuntu-branches/ubuntu/saucy/mupen64plus-video-rice/saucy

« back to all changes in this revision

Viewing changes to src/CritSect.h

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2011-01-22 11:05:28 UTC
  • Revision ID: james.westby@ubuntu.com-20110122110528-k6z84gdespqqd9zp
Tags: upstream-1.99.4
ImportĀ upstreamĀ versionĀ 1.99.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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