File indexing completed on 2025-07-11 08:13:57
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/timed_utils.hpp>
0043 #include <boost/interprocess/sync/detail/common_algorithms.hpp>
0044 #include <boost/assert.hpp>
0045
0046 #if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && \
0047 defined(BOOST_INTERPROCESS_POSIX_PROCESS_SHARED) && \
0048 defined (BOOST_INTERPROCESS_POSIX_RECURSIVE_MUTEXES)
0049 #include <boost/interprocess/sync/posix/recursive_mutex.hpp>
0050 #define BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_POSIX
0051 #elif !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS)
0052
0053 #include <boost/interprocess/sync/windows/recursive_mutex.hpp>
0054 #define BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_WINAPI
0055 #else
0056
0057 #include <boost/interprocess/sync/spin/recursive_mutex.hpp>
0058 namespace boost {
0059 namespace interprocess {
0060 namespace ipcdetail{
0061 namespace robust_emulation_helpers {
0062
0063 template<class T>
0064 class mutex_traits;
0065
0066 }}}}
0067 #endif
0068
0069 #endif
0070
0071
0072
0073
0074 namespace boost {
0075 namespace interprocess {
0076
0077
0078
0079
0080 class interprocess_recursive_mutex
0081 {
0082 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0083
0084 interprocess_recursive_mutex(const interprocess_recursive_mutex &);
0085 interprocess_recursive_mutex &operator=(const interprocess_recursive_mutex &);
0086 #endif
0087 public:
0088
0089
0090 interprocess_recursive_mutex();
0091
0092
0093
0094 ~interprocess_recursive_mutex();
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 void lock();
0106
0107
0108
0109
0110
0111
0112
0113
0114 bool try_lock();
0115
0116
0117
0118
0119
0120
0121
0122
0123 template<class TimePoint>
0124 bool timed_lock(const TimePoint &abs_time);
0125
0126
0127
0128 template<class TimePoint> bool try_lock_until(const TimePoint &abs_time)
0129 { return this->timed_lock(abs_time); }
0130
0131
0132
0133 template<class Duration> bool try_lock_for(const Duration &dur)
0134 { return this->timed_lock(ipcdetail::duration_to_ustime(dur)); }
0135
0136
0137
0138
0139
0140 void unlock();
0141 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0142 private:
0143
0144 #if defined(BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_POSIX)
0145 ipcdetail::posix_recursive_mutex mutex;
0146 #elif defined(BOOST_INTERPROCESS_RECURSIVE_MUTEX_USE_WINAPI)
0147 ipcdetail::winapi_recursive_mutex mutex;
0148 #else
0149 void take_ownership(){ mutex.take_ownership(); }
0150 friend class ipcdetail::robust_emulation_helpers::mutex_traits<interprocess_recursive_mutex>;
0151 ipcdetail::spin_recursive_mutex mutex;
0152 #endif
0153 #endif
0154 };
0155
0156 }
0157 }
0158
0159 namespace boost {
0160 namespace interprocess {
0161
0162 inline interprocess_recursive_mutex::interprocess_recursive_mutex(){}
0163
0164 inline interprocess_recursive_mutex::~interprocess_recursive_mutex(){}
0165
0166 inline void interprocess_recursive_mutex::lock()
0167 { ipcdetail::timeout_when_locking_aware_lock(mutex); }
0168
0169 inline bool interprocess_recursive_mutex::try_lock()
0170 { return mutex.try_lock(); }
0171
0172 template<class TimePoint>
0173 inline bool interprocess_recursive_mutex::timed_lock(const TimePoint &abs_time)
0174 { return mutex.timed_lock(abs_time); }
0175
0176 inline void interprocess_recursive_mutex::unlock()
0177 { mutex.unlock(); }
0178
0179 }
0180 }
0181
0182 #include <boost/interprocess/detail/config_end.hpp>
0183
0184 #endif