File indexing completed on 2025-01-18 09:51:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_SIGNALS2_LWM_PTHREADS_HPP
0013 #define BOOST_SIGNALS2_LWM_PTHREADS_HPP
0014
0015
0016
0017 #if defined(_MSC_VER)
0018 # pragma once
0019 #endif
0020
0021 #include <boost/assert.hpp>
0022 #include <pthread.h>
0023
0024 namespace boost
0025 {
0026
0027 namespace signals2
0028 {
0029
0030 class mutex
0031 {
0032 private:
0033
0034 pthread_mutex_t m_;
0035
0036 mutex(mutex const &);
0037 mutex & operator=(mutex const &);
0038
0039 public:
0040
0041 mutex()
0042 {
0043
0044
0045
0046 #if defined(__hpux) && defined(_DECTHREADS_)
0047 BOOST_VERIFY(pthread_mutex_init(&m_, pthread_mutexattr_default) == 0);
0048 #else
0049 BOOST_VERIFY(pthread_mutex_init(&m_, 0) == 0);
0050 #endif
0051 }
0052
0053 ~mutex()
0054 {
0055 BOOST_VERIFY(pthread_mutex_destroy(&m_) == 0);
0056 }
0057
0058 void lock()
0059 {
0060 BOOST_VERIFY(pthread_mutex_lock(&m_) == 0);
0061 }
0062
0063 bool try_lock()
0064 {
0065 return pthread_mutex_trylock(&m_) == 0;
0066 }
0067
0068 void unlock()
0069 {
0070 BOOST_VERIFY(pthread_mutex_unlock(&m_) == 0);
0071 }
0072 };
0073
0074 }
0075
0076 }
0077
0078 #endif