ext/boost/thread/pthread/mutex.hpp in passenger-3.0.21 vs ext/boost/thread/pthread/mutex.hpp in passenger-3.9.1.beta

- old
+ new

@@ -12,15 +12,15 @@ #include <boost/thread/locks.hpp> #include <boost/thread/thread_time.hpp> #include <boost/thread/xtime.hpp> #include <boost/assert.hpp> #include <errno.h> -#include "timespec.hpp" -#include "pthread_mutex_scoped_lock.hpp" +#include <boost/thread/pthread/timespec.hpp> +#include <boost/thread/pthread/pthread_mutex_scoped_lock.hpp> #ifdef _POSIX_TIMEOUTS -#if _POSIX_TIMEOUTS >= 0 +#if _POSIX_TIMEOUTS >= 0 && _POSIX_C_SOURCE>=200112L #define BOOST_PTHREAD_HAS_TIMEDLOCK #endif #endif #include <boost/config/abi_prefix.hpp> @@ -29,11 +29,11 @@ { class mutex { private: mutex(mutex const&); - mutex& operator=(mutex const&); + mutex& operator=(mutex const&); pthread_mutex_t m; public: mutex() { int const res=pthread_mutex_init(&m,NULL); @@ -46,45 +46,48 @@ { int ret; do { ret = pthread_mutex_destroy(&m); - } while(ret==EINTR); + } while (ret == EINTR); } - + void lock() { int res; do { res = pthread_mutex_lock(&m); - } while (res==EINTR); - if(res) { + } while (res == EINTR); + if(res) + { boost::throw_exception(lock_error(res)); } } void unlock() { int ret; do { ret = pthread_mutex_unlock(&m); - } while (ret==EINTR); + } while (ret == EINTR); BOOST_VERIFY(!ret); } - + bool try_lock() { int res; - do { + do + { res = pthread_mutex_trylock(&m); } while (res == EINTR); if(res && (res!=EBUSY)) { boost::throw_exception(lock_error(res)); } + return !res; } typedef pthread_mutex_t* native_handle_type; native_handle_type native_handle() @@ -100,11 +103,11 @@ class timed_mutex { private: timed_mutex(timed_mutex const&); - timed_mutex& operator=(timed_mutex const&); + timed_mutex& operator=(timed_mutex const&); private: pthread_mutex_t m; #ifndef BOOST_PTHREAD_HAS_TIMEDLOCK pthread_cond_t cond; bool is_locked; @@ -153,11 +156,11 @@ void unlock() { BOOST_VERIFY(!pthread_mutex_unlock(&m)); } - + bool try_lock() { int const res=pthread_mutex_trylock(&m); BOOST_ASSERT(!res || res==EBUSY); return !res; @@ -191,10 +194,10 @@ { boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); is_locked=false; BOOST_VERIFY(!pthread_cond_signal(&cond)); } - + bool try_lock() { boost::pthread::pthread_mutex_scoped_lock const local_lock(&m); if(is_locked) {