File indexing completed on 2026-03-30 08:05:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_MANAGED_XSI_SHARED_MEMORY_HPP
0012 #define BOOST_INTERPROCESS_MANAGED_XSI_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
0026 #if !defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS)
0027 #error "This header can't be used in operating systems without XSI (System V) shared memory support"
0028 #endif
0029
0030 #include <boost/interprocess/detail/managed_memory_impl.hpp>
0031 #include <boost/interprocess/detail/managed_open_or_create_impl.hpp>
0032 #include <boost/interprocess/detail/xsi_shared_memory_file_wrapper.hpp>
0033 #include <boost/interprocess/creation_tags.hpp>
0034
0035
0036 #include <boost/interprocess/mem_algo/rbtree_best_fit.hpp>
0037 #include <boost/interprocess/sync/mutex_family.hpp>
0038 #include <boost/interprocess/indexes/iset_index.hpp>
0039
0040 namespace boost {
0041
0042 namespace interprocess {
0043
0044 namespace ipcdetail {
0045
0046 template
0047 <
0048 class CharType,
0049 class AllocationAlgorithm,
0050 template<class IndexConfig> class IndexType
0051 >
0052 struct xsishmem_open_or_create
0053 {
0054 static const std::size_t segment_manager_alignment = boost::move_detail::alignment_of
0055 < segment_manager
0056 < CharType
0057 , AllocationAlgorithm
0058 , IndexType>
0059 >::value;
0060 static const std::size_t final_segment_manager_alignment
0061 = segment_manager_alignment > AllocationAlgorithm::Alignment
0062 ? segment_manager_alignment : AllocationAlgorithm::Alignment;
0063
0064 typedef ipcdetail::managed_open_or_create_impl
0065 < xsi_shared_memory_file_wrapper
0066 , final_segment_manager_alignment
0067 , false
0068 , true> type;
0069 };
0070
0071
0072 }
0073
0074
0075
0076
0077 template
0078 <
0079 class CharType,
0080 class AllocationAlgorithm,
0081 template<class IndexConfig> class IndexType
0082 >
0083 class basic_managed_xsi_shared_memory
0084 : public ipcdetail::basic_managed_memory_impl
0085 <CharType, AllocationAlgorithm, IndexType
0086 ,ipcdetail::xsishmem_open_or_create<CharType, AllocationAlgorithm, IndexType>
0087 ::type::ManagedOpenOrCreateUserOffset>
0088 , private ipcdetail::xsishmem_open_or_create
0089 <CharType, AllocationAlgorithm, IndexType>::type
0090 {
0091 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0092 public:
0093 typedef xsi_shared_memory_file_wrapper device_type;
0094
0095 public:
0096 typedef typename ipcdetail::xsishmem_open_or_create
0097 <CharType, AllocationAlgorithm, IndexType>::type base2_t;
0098 typedef ipcdetail::basic_managed_memory_impl
0099 <CharType, AllocationAlgorithm, IndexType,
0100 base2_t::ManagedOpenOrCreateUserOffset> base_t;
0101
0102 typedef ipcdetail::create_open_func<base_t> create_open_func_t;
0103
0104 basic_managed_xsi_shared_memory *get_this_pointer()
0105 { return this; }
0106
0107 private:
0108 typedef typename base_t::char_ptr_holder_t char_ptr_holder_t;
0109 BOOST_MOVABLE_BUT_NOT_COPYABLE(basic_managed_xsi_shared_memory)
0110 #endif
0111
0112 public:
0113 typedef typename base_t::size_type size_type;
0114
0115
0116
0117
0118
0119
0120
0121 ~basic_managed_xsi_shared_memory()
0122 {}
0123
0124
0125
0126 basic_managed_xsi_shared_memory() BOOST_NOEXCEPT
0127 {}
0128
0129
0130
0131 basic_managed_xsi_shared_memory(create_only_t, const xsi_key &key,
0132 std::size_t size, const void *addr = 0, const permissions& perm = permissions())
0133 : base_t()
0134 , base2_t(create_only, key, size, read_write, addr,
0135 create_open_func_t(get_this_pointer(), ipcdetail::DoCreate), perm)
0136 {}
0137
0138
0139
0140
0141
0142 basic_managed_xsi_shared_memory (open_or_create_t,
0143 const xsi_key &key, std::size_t size,
0144 const void *addr = 0, const permissions& perm = permissions())
0145 : base_t()
0146 , base2_t(open_or_create, key, size, read_write, addr,
0147 create_open_func_t(get_this_pointer(),
0148 ipcdetail::DoOpenOrCreate), perm)
0149 {}
0150
0151
0152
0153
0154 basic_managed_xsi_shared_memory (open_read_only_t, const xsi_key &key,
0155 const void *addr = 0)
0156 : base_t()
0157 , base2_t(open_only, key, read_only, addr,
0158 create_open_func_t(get_this_pointer(),
0159 ipcdetail::DoOpen))
0160 {}
0161
0162
0163
0164 basic_managed_xsi_shared_memory (open_only_t, const xsi_key &key,
0165 const void *addr = 0)
0166 : base_t()
0167 , base2_t(open_only, key, read_write, addr,
0168 create_open_func_t(get_this_pointer(),
0169 ipcdetail::DoOpen))
0170 {}
0171
0172
0173
0174 basic_managed_xsi_shared_memory(BOOST_RV_REF(basic_managed_xsi_shared_memory) moved) BOOST_NOEXCEPT
0175 {
0176 basic_managed_xsi_shared_memory tmp;
0177 this->swap(moved);
0178 tmp.swap(moved);
0179 }
0180
0181
0182
0183 basic_managed_xsi_shared_memory &operator=(BOOST_RV_REF(basic_managed_xsi_shared_memory) moved) BOOST_NOEXCEPT
0184 {
0185 basic_managed_xsi_shared_memory tmp(boost::move(moved));
0186 this->swap(tmp);
0187 return *this;
0188 }
0189
0190
0191
0192 void swap(basic_managed_xsi_shared_memory &other) BOOST_NOEXCEPT
0193 {
0194 base_t::swap(other);
0195 base2_t::swap(other);
0196 }
0197
0198
0199
0200
0201 static bool remove(int shmid)
0202 { return device_type::remove(shmid); }
0203
0204 int get_shmid() const BOOST_NOEXCEPT
0205 { return base2_t::get_device().get_shmid(); }
0206
0207 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0208
0209
0210
0211
0212 template <class T>
0213 std::pair<T*, std::size_t> find (char_ptr_holder_t name)
0214 {
0215 if(base2_t::get_mapped_region().get_mode() == read_only){
0216 return base_t::template find_no_lock<T>(name);
0217 }
0218 else{
0219 return base_t::template find<T>(name);
0220 }
0221 }
0222
0223 #endif
0224 };
0225
0226 #ifdef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0227
0228
0229
0230 typedef basic_managed_xsi_shared_memory
0231 <char
0232 ,rbtree_best_fit<mutex_family>
0233 ,iset_index>
0234 managed_xsi_shared_memory;
0235
0236
0237
0238 typedef basic_managed_xsi_shared_memory
0239 <wchar_t
0240 ,rbtree_best_fit<mutex_family>
0241 ,iset_index>
0242 wmanaged_xsi_shared_memory;
0243
0244 #endif
0245
0246 }
0247 }
0248
0249 #include <boost/interprocess/detail/config_end.hpp>
0250
0251 #endif
0252