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