15 #ifndef STXXL_COMMON_MUTEX_HEADER
16 #define STXXL_COMMON_MUTEX_HEADER
23 #elif STXXL_BOOST_THREADS
24 #include <boost/thread/mutex.hpp>
25 #elif STXXL_POSIX_THREADS
31 #error "Thread implementation not detected."
39 typedef std::mutex mutex;
41 #elif STXXL_BOOST_THREADS
43 typedef boost::mutex mutex;
45 #elif STXXL_POSIX_THREADS
62 int res = pthread_mutex_destroy(&m_mutex);
66 res = pthread_mutex_trylock(&m_mutex);
68 if (res == 0 || res == EBUSY) {
97 typedef std::unique_lock<std::mutex> scoped_mutex_lock;
99 #elif STXXL_BOOST_THREADS
101 typedef boost::mutex::scoped_lock scoped_mutex_lock;
117 : m_mutex(m), is_locked(true)
137 return m_mutex.native_handle();
145 #endif // !STXXL_COMMON_MUTEX_HEADER
~mutex()
destroy mutex handle
scoped_mutex_lock(mutex &m)
lock mutex
#define STXXL_CHECK_PTHREAD_CALL(expr)
Checks pthread call, if return != 0, throws stxxl::resource_error with "Error in [function] : [pthrea...
void unlock()
unlock mutex hold prematurely
bool is_locked
marker if already unlocked by this thread (needs no synchronization)
#define STXXL_THROW_ERRNO2(exception_type, error_message, errno_value)
Throws exception_type with "Error in [function] : [error_message] : [errno_value message]".
void lock()
lock mutex, may block
~scoped_mutex_lock()
unlock mutex hold when object goes out of scope.
pthread_mutex_t & native_handle()
return platform specific handle
Aquire a lock that's valid until the end of scope.
#define STXXL_BEGIN_NAMESPACE
pthread_mutex_t m_mutex
mutex handle
mutex()
construct unlocked mutex
mutex & m_mutex
mutex reference
void unlock()
unlock mutex
pthread_mutex_t & native_handle()
return platform specific handle
#define STXXL_END_NAMESPACE