File indexing completed on 2025-01-18 09:38:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef BOOST_INTERPROCESS_RECURSIVE_MUTEX_HPP
0028 #define BOOST_INTERPROCESS_RECURSIVE_MUTEX_HPP
0029
0030 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0031
0032 #ifndef BOOST_CONFIG_HPP
0033 # include <boost/config.hpp>
0034 #endif
0035 #
0036 #if defined(BOOST_HAS_PRAGMA_ONCE)
0037 # pragma once
0038 #endif
0039
0040 #include <boost/interprocess/detail/config_begin.hpp>
0041 #include <boost/interprocess/detail/workaround.hpp>
0042 #include <boost/interprocess/sync/detail/common_algorithms.hpp>
0043 #include <boost/assert.hpp>
0044
0045 #if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && \
0046 defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED) && \
0047 defined (BOOST_INTERPROCESS_POSIX_RECURSIVE_MUTEXES)
0048 #include <boost/interprocess/sync/posix/recursive_mutex.hpp>
0049 #define BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_POSIX
0050 #elif !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS)
0051
0052 #include <boost/interprocess/sync/windows/recursive_mutex.hpp>
0053 #define BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_WINAPI
0054 #else
0055
0056 #include <boost/interprocess/sync/spin/recursive_mutex.hpp>
0057 namespace boost {
0058 namespace interprocess {
0059 namespace ipcdetail{
0060 namespace robust_emulation_helpers {
0061
0062 template<class T>
0063 class mutex_traits;
0064
0065 }}}}
0066 #endif
0067
0068 #endif
0069
0070
0071
0072
0073 namespace boost {
0074 namespace interprocess {
0075
0076
0077
0078
0079 class interprocess_recursive_mutex
0080 {
0081 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0082
0083 interprocess_recursive_mutex(const interprocess_recursive_mutex &);
0084 interprocess_recursive_mutex &operator=(const interprocess_recursive_mutex &);
0085 #endif
0086 public:
0087
0088
0089 interprocess_recursive_mutex();
0090
0091
0092
0093 ~interprocess_recursive_mutex();
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 void lock();
0105
0106
0107
0108
0109
0110
0111
0112
0113 bool try_lock();
0114
0115
0116
0117
0118
0119
0120
0121
0122 template<class TimePoint>
0123 bool timed_lock(const TimePoint &abs_time);
0124
0125
0126
0127 template<class TimePoint> bool try_lock_until(const TimePoint &abs_time)
0128 { return this->timed_lock(abs_time); }
0129
0130
0131
0132 template<class Duration> bool try_lock_for(const Duration &dur)
0133 { return this->timed_lock(ipcdetail::duration_to_ustime(dur)); }
0134
0135
0136
0137
0138
0139 void unlock();
0140 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0141 private:
0142
0143 #if defined(BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_POSIX)
0144 ipcdetail::posix_recursive_mutex mutex;
0145 #elif defined(BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_WINAPI)
0146 ipcdetail::winapi_recursive_mutex mutex;
0147 #else
0148 void take_ownership(){ mutex.take_ownership(); }
0149 friend class ipcdetail::robust_emulation_helpers::mutex_traits<interprocess_recursive_mutex>;
0150 ipcdetail::spin_recursive_mutex mutex;
0151 #endif
0152 #endif
0153 };
0154
0155 }
0156 }
0157
0158 namespace boost {
0159 namespace interprocess {
0160
0161 inline interprocess_recursive_mutex::interprocess_recursive_mutex(){}
0162
0163 inline interprocess_recursive_mutex::~interprocess_recursive_mutex(){}
0164
0165 inline void interprocess_recursive_mutex::lock()
0166 { ipcdetail::timeout_when_locking_aware_lock(mutex); }
0167
0168 inline bool interprocess_recursive_mutex::try_lock()
0169 { return mutex.try_lock(); }
0170
0171 template<class TimePoint>
0172 inline bool interprocess_recursive_mutex::timed_lock(const TimePoint &abs_time)
0173 { return mutex.timed_lock(abs_time); }
0174
0175 inline void interprocess_recursive_mutex::unlock()
0176 { mutex.unlock(); }
0177
0178 }
0179 }
0180
0181 #include <boost/interprocess/detail/config_end.hpp>
0182
0183 #endif