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."
38 typedef std::mutex mutex;
40 #elif STXXL_BOOST_THREADS
42 typedef boost::mutex mutex;
44 #elif STXXL_POSIX_THREADS
61 int res = pthread_mutex_destroy(&m_mutex);
65 res = pthread_mutex_trylock(&m_mutex);
67 if (res == 0 || res == EBUSY) {
96 typedef std::unique_lock<std::mutex> scoped_mutex_lock;
98 #elif STXXL_BOOST_THREADS
100 typedef boost::mutex::scoped_lock scoped_mutex_lock;
116 : m_mutex(m), is_locked(true)
136 return m_mutex.native_handle();
144 #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