diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-23 22:44:30 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-23 22:44:30 +0100 |
commit | 1ea7f90eec9e1c9d68dd840edafe9b831200743d (patch) | |
tree | 12f801dd068299ef0bf5d30d16b7dfdbda1812aa /src/mutex.h | |
parent | 64206ea00feee4bcb2c1f52fa9d63b925cdf1d4d (diff) |
Possible fix to missing std::mutex in mingw.
Diffstat (limited to 'src/mutex.h')
-rw-r--r-- | src/mutex.h | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/mutex.h b/src/mutex.h index 11704d4..9364515 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -25,31 +25,42 @@ * along with Pracro; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __PRACRO_MUTEX_H__ -#define __PRACRO_MUTEX_H__ +#pragma once struct mutex_private_t; class Mutex { public: - Mutex(); - ~Mutex(); + Mutex(); + ~Mutex(); - bool trylock(); - void lock(); - void unlock(); + bool trylock(); + void lock(); + void unlock(); private: - struct mutex_private_t* prv; + struct mutex_private_t* prv; }; +#ifdef WIN32 +// Hack: mingw doesn't have std::mutex +namespace std { + class mutex + : public Mutex { + public: + bool try_lock() + { + return trylock(); + } + }; +} +#endif + class MutexAutolock { public: - MutexAutolock(Mutex &mutex); - ~MutexAutolock(); + MutexAutolock(Mutex &mutex); + ~MutexAutolock(); private: - Mutex &mutex; + Mutex &mutex; }; - -#endif/*__PRACRO_MUTEX_H__*/ |