5 #ifndef BALL_SYSTEM_MUTEX_H
6 #define BALL_SYSTEM_MUTEX_H
8 #ifndef BALL_COMMON_GLOBAL_H
12 #include <QtCore/QMutex>
13 #include <QtCore/QReadWriteLock>
14 #include <QtCore/QMutexLocker>
15 #include <QtCore/QReadLocker>
16 #include <QtCore/QWriteLocker>
18 #ifdef BALL_HAS_BOOST_THREAD
19 # include <boost/version.hpp>
20 # if BOOST_VERSION >= 103500
21 # include <boost/thread/mutex.hpp>
22 # define BALL_HAS_BOOST_MUTEX
26 #undef BALL_USE_THREAD_CHECKER_API
27 #ifdef BALL_USE_THREAD_CHECKER_API
28 # include <libittnotify.h>
31 #define BALL_DEFAULT_MUTEX_TYPE QMutex
32 #define BALL_DEFAULT_MUTEXLOCKER_TYPE QMutexLocker
33 #define BALL_DEFAULT_READWRITELOCK_TYPE QReadWriteLock
34 #define BALL_DEFAULT_READLOCKER_TYPE QReadLocker
35 #define BALL_DEFAULT_WRITELOCKER_TYPE QWriteLocker
46 template <
class MutexType>
62 : QMutex( is_recursive ? Recursive : NonRecursive )
77 template <
class MutexLockerType,
class MutexType>
95 template <
class ReadWriteLockType>
107 :
public QReadWriteLock
112 #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
113 : QReadWriteLock( is_recursive ? Recursive : NonRecursive )
131 template <
class ReadLockerType,
class ReadWriteLockType>
151 template <
class WriteLockerType,
class ReadWriteLockType>
163 #ifdef BALL_HAS_BOOST_MUTEX
166 class TMutex<boost::mutex>
167 :
public boost::mutex
176 return boost::mutex::lock();
188 #ifdef BALL_USE_THREAD_CHECKER_API
201 __itt_notify_sync_prepare((
void *)
this);
203 __itt_notify_sync_acquired((
void*)
this);
208 __itt_notify_sync_releasing((
void *)
this);
214 __itt_notify_sync_prepare((
void*)
this);
215 bool result = QMutex::tryLock();
218 __itt_notify_sync_acquired((
void*)
this);
220 __itt_notify_sync_cancel((
void*)
this);
230 #ifdef BALL_COMPILER_MSVC
233 template class BALL_EXPORT TMutexLocker<BALL_DEFAULT_MUTEXLOCKER_TYPE, BALL_DEFAULT_MUTEX_TYPE>;
234 template class BALL_EXPORT TReadLocker<BALL_DEFAULT_READLOCKER_TYPE, BALL_DEFAULT_READWRITELOCK_TYPE>;
235 template class BALL_EXPORT TWriteLocker<BALL_DEFAULT_WRITELOCKER_TYPE, BALL_DEFAULT_READWRITELOCK_TYPE>;
247 #endif // BALL_SYSTEM_MUTEX_H
TReadWriteLock(bool is_recursive=false)
TReadWriteLock< BALL_DEFAULT_READWRITELOCK_TYPE > ReadWriteLock
TReadLocker< BALL_DEFAULT_READLOCKER_TYPE, BALL_DEFAULT_READWRITELOCK_TYPE > ReadLocker
TWriteLocker< BALL_DEFAULT_WRITELOCKER_TYPE, BALL_DEFAULT_READWRITELOCK_TYPE > WriteLocker
TMutex(bool is_recursive=false)
TReadWriteLock(bool is_recursive=false)
TReadLocker(ReadWriteLockType *lock)
TMutex(bool is_recursive=false)
TMutex< BALL_DEFAULT_MUTEX_TYPE > Mutex
TMutexLocker< BALL_DEFAULT_MUTEXLOCKER_TYPE, BALL_DEFAULT_MUTEX_TYPE > MutexLocker
TWriteLocker(ReadWriteLockType *lock)
TMutexLocker(MutexType *mutex)