File indexing completed on 2026-09-10 08:49:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_MANAGED_WINDOWS_SHARED_MEMORY_HPP
0012 #define BOOST_INTERPROCESS_MANAGED_WINDOWS_SHARED_MEMORY_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 # pragma once
0021 #endif
0022
0023 #include <boost/interprocess/detail/config_begin.hpp>
0024 #include <boost/interprocess/detail/workaround.hpp>
0025 #include <boost/interprocess/detail/managed_open_or_create_impl.hpp>
0026 #include <boost/interprocess/detail/managed_memory_impl.hpp>
0027 #include <boost/interprocess/creation_tags.hpp>
0028 #include <boost/interprocess/windows_shared_memory.hpp>
0029 #include <boost/interprocess/permissions.hpp>
0030 #include <boost/move/utility_core.hpp>
0031
0032
0033 #include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
0034 #include <boost/interprocess/sync/mutex_family.hpp>
0035 #include <boost/interprocess/indexes/iset_index.hpp>
0036
0037 namespace boost {
0038 namespace interprocess {
0039
0040 namespace ipcdetail {
0041
0042 template
0043 <
0044 class CharType,
0045 class AllocationAlgorithm,
0046 template<class IndexConfig> class IndexType
0047 >
0048 struct wshmem_open_or_create
0049 {
0050 static const std::size_t segment_manager_alignment = boost::move_detail::alignment_of
0051 < segment_manager
0052 < CharType
0053 , AllocationAlgorithm
0054 , IndexType>
0055 >::value;
0056 static const std::size_t final_segment_manager_alignment
0057 = segment_manager_alignment > AllocationAlgorithm::Alignment
0058 ? segment_manager_alignment : AllocationAlgorithm::Alignment;
0059
0060 typedef ipcdetail::managed_open_or_create_impl
0061 < windows_shared_memory
0062 , final_segment_manager_alignment
0063 , false
0064 , false> type;
0065 };
0066
0067
0068 }
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 template
0082 <
0083 class CharType,
0084 class AllocationAlgorithm,
0085 template<class IndexConfig> class IndexType
0086 >
0087 class basic_managed_windows_shared_memory
0088 : public ipcdetail::basic_managed_memory_impl
0089 < CharType, AllocationAlgorithm, IndexType
0090 , ipcdetail::wshmem_open_or_create
0091 <CharType, AllocationAlgorithm, IndexType>::type::ManagedOpenOrCreateUserOffset>
0092 {
0093 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0094 private:
0095 typedef ipcdetail::basic_managed_memory_impl
0096 < CharType, AllocationAlgorithm, IndexType
0097 , ipcdetail::wshmem_open_or_create
0098 <CharType, AllocationAlgorithm, IndexType>::type::ManagedOpenOrCreateUserOffset> base_t;
0099 typedef ipcdetail::create_open_func<base_t> create_open_func_t;
0100
0101 basic_managed_windows_shared_memory *get_this_pointer()
0102 { return this; }
0103
0104 private:
0105 typedef typename base_t::char_ptr_holder_t char_ptr_holder_t;
0106 BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_managed_windows_shared_memory)
0107 #endif
0108
0109 public:
0110 typedef typename base_t::size_type size_type;
0111
0112
0113
0114 basic_managed_windows_shared_memory() BOOST_NOEXCEPT
0115 {}
0116
0117
0118
0119 basic_managed_windows_shared_memory
0120 (create_only_t, const char *name,
0121 size_type size, const void *addr = 0, const permissions &perm = permissions())
0122 : m_wshm(create_only, name, size, read_write, addr,
0123 create_open_func_t(get_this_pointer(), ipcdetail::DoCreate), perm)
0124 {}
0125
0126
0127
0128
0129
0130 basic_managed_windows_shared_memory
0131 (open_or_create_t,
0132 const char *name, size_type size,
0133 const void *addr = 0,
0134 const permissions &perm = permissions())
0135 : m_wshm(open_or_create, name, size, read_write, addr,
0136 create_open_func_t(get_this_pointer(),
0137 ipcdetail::DoOpenOrCreate), perm)
0138 {}
0139
0140
0141
0142 basic_managed_windows_shared_memory
0143 (open_only_t, const char* name, const void *addr = 0)
0144 : m_wshm(open_only, name, read_write, addr,
0145 create_open_func_t(get_this_pointer(),
0146 ipcdetail::DoOpen))
0147 {}
0148
0149
0150
0151
0152 basic_managed_windows_shared_memory
0153 (open_copy_on_write_t, const char* name, const void *addr = 0)
0154 : m_wshm(open_only, name, copy_on_write, addr,
0155 create_open_func_t(get_this_pointer(), ipcdetail::DoOpen))
0156 {}
0157
0158
0159
0160
0161 basic_managed_windows_shared_memory
0162 (open_read_only_t, const char* name, const void *addr = 0)
0163 : base_t()
0164 , m_wshm(open_only, name, read_only, addr,
0165 create_open_func_t(get_this_pointer(), ipcdetail::DoOpen))
0166 {}
0167
0168
0169
0170
0171
0172 basic_managed_windows_shared_memory
0173 (open_or_create_t,
0174 const wchar_t *name, size_type size,
0175 const void *addr = 0,
0176 const permissions &perm = permissions())
0177 : m_wshm(open_or_create, name, size, read_write, addr,
0178 create_open_func_t(get_this_pointer(),
0179 ipcdetail::DoOpenOrCreate), perm)
0180 {}
0181
0182
0183
0184 basic_managed_windows_shared_memory
0185 (open_only_t, const wchar_t* name, const void *addr = 0)
0186 : m_wshm(open_only, name, read_write, addr,
0187 create_open_func_t(get_this_pointer(),
0188 ipcdetail::DoOpen))
0189 {}
0190
0191
0192
0193
0194 basic_managed_windows_shared_memory
0195 (open_copy_on_write_t, const wchar_t* name, const void *addr = 0)
0196 : m_wshm(open_only, name, copy_on_write, addr,
0197 create_open_func_t(get_this_pointer(), ipcdetail::DoOpen))
0198 {}
0199
0200
0201
0202
0203 basic_managed_windows_shared_memory
0204 (open_read_only_t, const wchar_t* name, const void *addr = 0)
0205 : base_t()
0206 , m_wshm(open_only, name, read_only, addr,
0207 create_open_func_t(get_this_pointer(), ipcdetail::DoOpen))
0208 {}
0209
0210
0211
0212 basic_managed_windows_shared_memory
0213 (BOOST_RV_REF(basic_managed_windows_shared_memory) moved) BOOST_NOEXCEPT
0214 { this->swap(moved); }
0215
0216
0217
0218 basic_managed_windows_shared_memory &operator=(BOOST_RV_REF(basic_managed_windows_shared_memory) moved) BOOST_NOEXCEPT
0219 {
0220 basic_managed_windows_shared_memory tmp(boost::move(moved));
0221 this->swap(tmp);
0222 return *this;
0223 }
0224
0225
0226
0227
0228
0229
0230 ~basic_managed_windows_shared_memory()
0231 {}
0232
0233
0234
0235 void swap(basic_managed_windows_shared_memory &other) BOOST_NOEXCEPT
0236 {
0237 base_t::swap(other);
0238 m_wshm.swap(other.m_wshm);
0239 }
0240
0241 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0242
0243
0244
0245
0246 template <class T>
0247 std::pair<T*, size_type> find (char_ptr_holder_t name)
0248 {
0249 if(m_wshm.get_mapped_region().get_mode() == read_only){
0250 return base_t::template find_no_lock<T>(name);
0251 }
0252 else{
0253 return base_t::template find<T>(name);
0254 }
0255 }
0256
0257 private:
0258 typename ipcdetail::wshmem_open_or_create
0259 <CharType, AllocationAlgorithm, IndexType>::type m_wshm;
0260 #endif
0261 };
0262
0263 #ifdef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0264
0265
0266
0267 typedef basic_managed_windows_shared_memory
0268 <char
0269 ,rbtree_best_fit<mutex_family>
0270 ,iset_index>
0271 managed_windows_shared_memory;
0272
0273
0274
0275 typedef basic_managed_windows_shared_memory
0276 <wchar_t
0277 ,rbtree_best_fit<mutex_family>
0278 ,iset_index>
0279 wmanaged_windows_shared_memory;
0280
0281 #endif
0282
0283
0284 }
0285 }
0286
0287 #include <boost/interprocess/detail/config_end.hpp>
0288
0289 #endif