File indexing completed on 2025-01-18 09:38:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_NAMED_RECURSIVE_MUTEX_HPP
0012 #define BOOST_INTERPROCESS_NAMED_RECURSIVE_MUTEX_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 #include <boost/interprocess/creation_tags.hpp>
0025 #include <boost/interprocess/permissions.hpp>
0026
0027 #if !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) && defined (BOOST_INTERPROCESS_WINDOWS)
0028 #include <boost/interprocess/sync/windows/named_recursive_mutex.hpp>
0029 #define BOOST_INTERPROCESS_NAMED_RECURSIVE_MUTEX_USE_WINAPI
0030 #else
0031 #include <boost/interprocess/sync/shm/named_recursive_mutex.hpp>
0032 #endif
0033
0034
0035
0036
0037 namespace boost {
0038 namespace interprocess {
0039
0040 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0041 namespace ipcdetail{ class interprocess_tester; }
0042 #endif
0043
0044
0045
0046
0047 class named_recursive_mutex
0048 {
0049 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0050
0051 named_recursive_mutex();
0052 named_recursive_mutex(const named_recursive_mutex &);
0053 named_recursive_mutex &operator=(const named_recursive_mutex &);
0054 #endif
0055 public:
0056
0057
0058
0059 named_recursive_mutex(create_only_t, const char *name, const permissions &perm = permissions());
0060
0061
0062
0063
0064
0065
0066
0067 named_recursive_mutex(open_or_create_t, const char *name, const permissions &perm = permissions());
0068
0069
0070
0071
0072 named_recursive_mutex(open_only_t, const char *name);
0073
0074 #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0075
0076
0077
0078
0079
0080
0081 named_recursive_mutex(create_only_t, const wchar_t *name, const permissions &perm = permissions());
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 named_recursive_mutex(open_or_create_t, const wchar_t *name, const permissions &perm = permissions());
0093
0094
0095
0096
0097
0098
0099
0100 named_recursive_mutex(open_only_t, const wchar_t *name);
0101
0102 #endif
0103
0104
0105
0106
0107
0108
0109
0110 ~named_recursive_mutex();
0111
0112
0113
0114 void unlock();
0115
0116
0117
0118
0119
0120
0121 void lock();
0122
0123
0124
0125
0126
0127
0128
0129 bool try_lock();
0130
0131
0132
0133
0134
0135
0136
0137 template<class TimePoint>
0138 bool timed_lock(const TimePoint &abs_time);
0139
0140
0141
0142 template<class TimePoint> bool try_lock_until(const TimePoint &abs_time)
0143 { return this->timed_lock(abs_time); }
0144
0145
0146
0147 template<class Duration> bool try_lock_for(const Duration &dur)
0148 { return this->timed_lock(ipcdetail::duration_to_ustime(dur)); }
0149
0150
0151
0152 static bool remove(const char *name);
0153
0154 #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0155
0156
0157
0158
0159
0160 static bool remove(const wchar_t *name);
0161 #endif
0162
0163 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0164 private:
0165 friend class ipcdetail::interprocess_tester;
0166 void dont_close_on_destruction();
0167
0168 #if defined(BOOST_INTERPROCESS_NAMED_RECURSIVE_MUTEX_USE_WINAPI)
0169 typedef ipcdetail::winapi_named_recursive_mutex impl_t;
0170 #else
0171 typedef ipcdetail::shm_named_recursive_mutex impl_t;
0172 #endif
0173 impl_t m_mut;
0174
0175 #endif
0176 };
0177
0178 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0179
0180 inline named_recursive_mutex::~named_recursive_mutex()
0181 {}
0182
0183 inline void named_recursive_mutex::dont_close_on_destruction()
0184 { ipcdetail::interprocess_tester::dont_close_on_destruction(m_mut); }
0185
0186 inline named_recursive_mutex::named_recursive_mutex(create_only_t, const char *name, const permissions &perm)
0187 : m_mut (create_only, name, perm)
0188 {}
0189
0190 inline named_recursive_mutex::named_recursive_mutex(open_or_create_t, const char *name, const permissions &perm)
0191 : m_mut (open_or_create, name, perm)
0192 {}
0193
0194 inline named_recursive_mutex::named_recursive_mutex(open_only_t, const char *name)
0195 : m_mut (open_only, name)
0196 {}
0197
0198 #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0199
0200 inline named_recursive_mutex::named_recursive_mutex(create_only_t, const wchar_t *name, const permissions &perm)
0201 : m_mut (create_only, name, perm)
0202 {}
0203
0204 inline named_recursive_mutex::named_recursive_mutex(open_or_create_t, const wchar_t *name, const permissions &perm)
0205 : m_mut (open_or_create, name, perm)
0206 {}
0207
0208 inline named_recursive_mutex::named_recursive_mutex(open_only_t, const wchar_t *name)
0209 : m_mut (open_only, name)
0210 {}
0211
0212 #endif
0213
0214 inline void named_recursive_mutex::lock()
0215 { m_mut.lock(); }
0216
0217 inline void named_recursive_mutex::unlock()
0218 { m_mut.unlock(); }
0219
0220 inline bool named_recursive_mutex::try_lock()
0221 { return m_mut.try_lock(); }
0222
0223 template<class TimePoint>
0224 inline bool named_recursive_mutex::timed_lock(const TimePoint &abs_time)
0225 { return m_mut.timed_lock(abs_time); }
0226
0227 inline bool named_recursive_mutex::remove(const char *name)
0228 { return impl_t::remove(name); }
0229
0230 #if defined(BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0231
0232 inline bool named_recursive_mutex::remove(const wchar_t *name)
0233 { return impl_t::remove(name); }
0234
0235 #endif
0236
0237 #endif
0238
0239 }
0240 }
0241
0242 #include <boost/interprocess/detail/config_end.hpp>
0243
0244 #endif