ScummVM API documentation
mutex.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_MUTEX_H
23 #define COMMON_MUTEX_H
24 
25 #include "common/scummsys.h"
26 #include "common/system.h"
27 
28 namespace Common {
29 
38 class Mutex;
39 
41 public:
42  virtual ~MutexInternal() {}
43 
44  virtual bool lock() = 0;
45  virtual bool unlock() = 0;
46 };
47 
51 class StackLock {
52  MutexInternal *_mutex;
53  const char *_mutexName;
54 
55  bool lock();
56  bool unlock();
57 public:
58  explicit StackLock(MutexInternal *mutex, const char *mutexName = nullptr);
59  explicit StackLock(const Mutex &mutex, const char *mutexName = nullptr);
60  ~StackLock();
61 };
62 
63 
67 class Mutex {
68  friend class StackLock;
69 
70  MutexInternal *_mutex;
71 
72 public:
73  Mutex();
74  ~Mutex();
75 
76  bool lock();
77  bool unlock();
78 };
79 
82 } // End of namespace Common
83 
84 #endif
Definition: mutex.h:51
Definition: algorithm.h:29
Definition: mutex.h:67
Definition: mutex.h:40