summaryrefslogtreecommitdiff
path: root/src/debug/fast_mutex.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-28 20:06:51 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-28 20:06:51 +0300
commit3b8a3b84346700abffa52745245310bf3eae6b18 (patch)
treedfe8c94d73da7fc3a350017f1905f3e25b5ec5e0 /src/debug/fast_mutex.h
parent1c1860cf83ba5d504b69c0ebd737139c8ab1bd46 (diff)
downloadmanaverse-3b8a3b84346700abffa52745245310bf3eae6b18.tar.gz
manaverse-3b8a3b84346700abffa52745245310bf3eae6b18.tar.bz2
manaverse-3b8a3b84346700abffa52745245310bf3eae6b18.tar.xz
manaverse-3b8a3b84346700abffa52745245310bf3eae6b18.zip
Fix formating in other files.
Diffstat (limited to 'src/debug/fast_mutex.h')
-rw-r--r--src/debug/fast_mutex.h310
1 files changed, 155 insertions, 155 deletions
diff --git a/src/debug/fast_mutex.h b/src/debug/fast_mutex.h
index 5c6471fae..8bedd3aeb 100644
--- a/src/debug/fast_mutex.h
+++ b/src/debug/fast_mutex.h
@@ -118,64 +118,64 @@
*/
class fast_mutex
{
- pthread_mutex_t _M_mtx_impl;
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- bool _M_initialized;
-# endif
-# ifdef _DEBUG
- bool _M_locked;
-# endif
- public:
- fast_mutex()
-# ifdef _DEBUG
- : _M_locked(false)
-# endif
- {
- ::pthread_mutex_init(&_M_mtx_impl, nullptr);
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = true;
-# endif
- }
- ~fast_mutex()
- {
- _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = false;
-# endif
- ::pthread_mutex_destroy(&_M_mtx_impl);
- }
- void lock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
- ::pthread_mutex_lock(&_M_mtx_impl);
-# ifdef _DEBUG
- // The following assertion should _always_ be true for a
- // real `fast' pthread_mutex. However, this assertion can
- // help sometimes, when people forget to use `-lpthread' and
- // glibc provides an empty implementation. Having this
- // assertion is also more consistent.
- _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
- _M_locked = true;
-# endif
- }
- void unlock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
- _M_locked = false;
-# endif
- ::pthread_mutex_unlock(&_M_mtx_impl);
- }
- private:
- fast_mutex(const fast_mutex&);
- fast_mutex& operator=(const fast_mutex&);
+ pthread_mutex_t _M_mtx_impl;
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ bool _M_initialized;
+# endif
+# ifdef _DEBUG
+ bool _M_locked;
+# endif
+ public:
+ fast_mutex()
+# ifdef _DEBUG
+ : _M_locked(false)
+# endif
+ {
+ ::pthread_mutex_init(&_M_mtx_impl, nullptr);
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ _M_initialized = true;
+# endif
+ }
+ ~fast_mutex()
+ {
+ _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ _M_initialized = false;
+# endif
+ ::pthread_mutex_destroy(&_M_mtx_impl);
+ }
+ void lock()
+ {
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ if (!_M_initialized)
+ return;
+# endif
+ ::pthread_mutex_lock(&_M_mtx_impl);
+# ifdef _DEBUG
+ // The following assertion should _always_ be true for a
+ // real `fast' pthread_mutex. However, this assertion can
+ // help sometimes, when people forget to use `-lpthread' and
+ // glibc provides an empty implementation. Having this
+ // assertion is also more consistent.
+ _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
+ _M_locked = true;
+# endif
+ }
+ void unlock()
+ {
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ if (!_M_initialized)
+ return;
+# endif
+# ifdef _DEBUG
+ _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
+ _M_locked = false;
+# endif
+ ::pthread_mutex_unlock(&_M_mtx_impl);
+ }
+ private:
+ fast_mutex(const fast_mutex&);
+ fast_mutex& operator=(const fast_mutex&);
};
# endif // _PTHREADS
@@ -192,59 +192,59 @@
*/
class fast_mutex
{
- CRITICAL_SECTION _M_mtx_impl;
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- bool _M_initialized;
-# endif
-# ifdef _DEBUG
- bool _M_locked;
-# endif
- public:
- fast_mutex()
-# ifdef _DEBUG
- : _M_locked(false)
-# endif
- {
- ::InitializeCriticalSection(&_M_mtx_impl);
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = true;
-# endif
- }
- ~fast_mutex()
- {
- _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- _M_initialized = false;
-# endif
- ::DeleteCriticalSection(&_M_mtx_impl);
- }
- void lock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
- ::EnterCriticalSection(&_M_mtx_impl);
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
- _M_locked = true;
-# endif
- }
- void unlock()
- {
-# if _FAST_MUTEX_CHECK_INITIALIZATION
- if (!_M_initialized)
- return;
-# endif
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
- _M_locked = false;
-# endif
- ::LeaveCriticalSection(&_M_mtx_impl);
- }
- private:
- fast_mutex(const fast_mutex&);
- fast_mutex& operator=(const fast_mutex&);
+ CRITICAL_SECTION _M_mtx_impl;
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ bool _M_initialized;
+# endif
+# ifdef _DEBUG
+ bool _M_locked;
+# endif
+ public:
+ fast_mutex()
+# ifdef _DEBUG
+ : _M_locked(false)
+# endif
+ {
+ ::InitializeCriticalSection(&_M_mtx_impl);
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ _M_initialized = true;
+# endif
+ }
+ ~fast_mutex()
+ {
+ _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ _M_initialized = false;
+# endif
+ ::DeleteCriticalSection(&_M_mtx_impl);
+ }
+ void lock()
+ {
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ if (!_M_initialized)
+ return;
+# endif
+ ::EnterCriticalSection(&_M_mtx_impl);
+# ifdef _DEBUG
+ _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
+ _M_locked = true;
+# endif
+ }
+ void unlock()
+ {
+# if _FAST_MUTEX_CHECK_INITIALIZATION
+ if (!_M_initialized)
+ return;
+# endif
+# ifdef _DEBUG
+ _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
+ _M_locked = false;
+# endif
+ ::LeaveCriticalSection(&_M_mtx_impl);
+ }
+ private:
+ fast_mutex(const fast_mutex&);
+ fast_mutex& operator=(const fast_mutex&);
};
# endif // _WIN32THREADS
@@ -260,56 +260,56 @@
*/
class fast_mutex
{
-# ifdef _DEBUG
- bool _M_locked;
-# endif
- public:
- fast_mutex()
-# ifdef _DEBUG
- : _M_locked(false)
-# endif
- {
- }
- ~fast_mutex()
- {
- _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
- }
- void lock()
- {
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
- _M_locked = true;
-# endif
- }
- void unlock()
- {
-# ifdef _DEBUG
- _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
- _M_locked = false;
-# endif
- }
- private:
- fast_mutex(const fast_mutex&);
- fast_mutex& operator=(const fast_mutex&);
+# ifdef _DEBUG
+ bool _M_locked;
+# endif
+ public:
+ fast_mutex()
+# ifdef _DEBUG
+ : _M_locked(false)
+# endif
+ {
+ }
+ ~fast_mutex()
+ {
+ _FAST_MUTEX_ASSERT(!_M_locked, "~fast_mutex(): still locked");
+ }
+ void lock()
+ {
+# ifdef _DEBUG
+ _FAST_MUTEX_ASSERT(!_M_locked, "lock(): already locked");
+ _M_locked = true;
+# endif
+ }
+ void unlock()
+ {
+# ifdef _DEBUG
+ _FAST_MUTEX_ASSERT(_M_locked, "unlock(): not locked");
+ _M_locked = false;
+# endif
+ }
+ private:
+ fast_mutex(const fast_mutex&);
+ fast_mutex& operator=(const fast_mutex&);
};
# endif // _NOTHREADS
/** An acquistion-on-initialization lock class based on fast_mutex. */
class fast_mutex_autolock
{
- fast_mutex& _M_mtx;
-public:
- explicit fast_mutex_autolock(fast_mutex& __mtx) : _M_mtx(__mtx)
- {
- _M_mtx.lock();
- }
- ~fast_mutex_autolock()
- {
- _M_mtx.unlock();
- }
-private:
- fast_mutex_autolock(const fast_mutex_autolock&);
- fast_mutex_autolock& operator=(const fast_mutex_autolock&);
+ fast_mutex& _M_mtx;
+ public:
+ explicit fast_mutex_autolock(fast_mutex& __mtx) : _M_mtx(__mtx)
+ {
+ _M_mtx.lock();
+ }
+ ~fast_mutex_autolock()
+ {
+ _M_mtx.unlock();
+ }
+ private:
+ fast_mutex_autolock(const fast_mutex_autolock&);
+ fast_mutex_autolock& operator=(const fast_mutex_autolock&);
};
#endif // M_FAST_MUTEX_H