Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
|
Chris@16
|
4 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 //
|
Chris@16
|
7 // See http://www.boost.org/libs/interprocess for documentation.
|
Chris@16
|
8 //
|
Chris@16
|
9 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_INTERPROCESS_PRIVATE_ADAPTIVE_POOL_HPP
|
Chris@16
|
12 #define BOOST_INTERPROCESS_PRIVATE_ADAPTIVE_POOL_HPP
|
Chris@16
|
13
|
Chris@101
|
14 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
15 # include <boost/config.hpp>
|
Chris@101
|
16 #endif
|
Chris@101
|
17 #
|
Chris@101
|
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@16
|
19 # pragma once
|
Chris@16
|
20 #endif
|
Chris@16
|
21
|
Chris@16
|
22 #include <boost/interprocess/detail/config_begin.hpp>
|
Chris@16
|
23 #include <boost/interprocess/detail/workaround.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/interprocess/interprocess_fwd.hpp>
|
Chris@16
|
28 #include <boost/assert.hpp>
|
Chris@16
|
29 #include <boost/utility/addressof.hpp>
|
Chris@16
|
30 #include <boost/interprocess/allocators/detail/adaptive_node_pool.hpp>
|
Chris@101
|
31 #include <boost/interprocess/containers/version_type.hpp>
|
Chris@16
|
32 #include <boost/container/detail/multiallocation_chain.hpp>
|
Chris@16
|
33 #include <boost/interprocess/exceptions.hpp>
|
Chris@16
|
34 #include <boost/interprocess/detail/utilities.hpp>
|
Chris@16
|
35 #include <boost/interprocess/detail/workaround.hpp>
|
Chris@101
|
36 #include <boost/move/adl_move_swap.hpp>
|
Chris@16
|
37 #include <cstddef>
|
Chris@16
|
38
|
Chris@16
|
39 //!\file
|
Chris@16
|
40 //!Describes private_adaptive_pool_base pooled shared memory STL compatible allocator
|
Chris@16
|
41
|
Chris@16
|
42 namespace boost {
|
Chris@16
|
43 namespace interprocess {
|
Chris@16
|
44
|
Chris@101
|
45 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
Chris@16
|
46
|
Chris@16
|
47 namespace ipcdetail {
|
Chris@16
|
48
|
Chris@16
|
49 template < unsigned int Version
|
Chris@16
|
50 , class T
|
Chris@16
|
51 , class SegmentManager
|
Chris@16
|
52 , std::size_t NodesPerBlock
|
Chris@16
|
53 , std::size_t MaxFreeBlocks
|
Chris@16
|
54 , unsigned char OverheadPercent
|
Chris@16
|
55 >
|
Chris@16
|
56 class private_adaptive_pool_base
|
Chris@16
|
57 : public node_pool_allocation_impl
|
Chris@16
|
58 < private_adaptive_pool_base < Version, T, SegmentManager, NodesPerBlock
|
Chris@16
|
59 , MaxFreeBlocks, OverheadPercent>
|
Chris@16
|
60 , Version
|
Chris@16
|
61 , T
|
Chris@16
|
62 , SegmentManager
|
Chris@16
|
63 >
|
Chris@16
|
64 {
|
Chris@16
|
65 public:
|
Chris@16
|
66 //Segment manager
|
Chris@16
|
67 typedef SegmentManager segment_manager;
|
Chris@16
|
68 typedef typename SegmentManager::void_pointer void_pointer;
|
Chris@16
|
69
|
Chris@101
|
70 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
Chris@16
|
71 private:
|
Chris@16
|
72 typedef private_adaptive_pool_base
|
Chris@16
|
73 < Version, T, SegmentManager, NodesPerBlock
|
Chris@16
|
74 , MaxFreeBlocks, OverheadPercent> self_t;
|
Chris@16
|
75 typedef ipcdetail::private_adaptive_node_pool
|
Chris@16
|
76 <SegmentManager
|
Chris@16
|
77 , sizeof_value<T>::value
|
Chris@16
|
78 , NodesPerBlock
|
Chris@16
|
79 , MaxFreeBlocks
|
Chris@16
|
80 , OverheadPercent
|
Chris@16
|
81 > node_pool_t;
|
Chris@16
|
82
|
Chris@16
|
83 BOOST_STATIC_ASSERT((Version <=2));
|
Chris@16
|
84
|
Chris@101
|
85 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
86
|
Chris@16
|
87 public:
|
Chris@16
|
88 typedef typename boost::intrusive::
|
Chris@16
|
89 pointer_traits<void_pointer>::template
|
Chris@16
|
90 rebind_pointer<T>::type pointer;
|
Chris@16
|
91 typedef typename boost::intrusive::
|
Chris@16
|
92 pointer_traits<void_pointer>::template
|
Chris@16
|
93 rebind_pointer<const T>::type const_pointer;
|
Chris@16
|
94 typedef T value_type;
|
Chris@16
|
95 typedef typename ipcdetail::add_reference
|
Chris@16
|
96 <value_type>::type reference;
|
Chris@16
|
97 typedef typename ipcdetail::add_reference
|
Chris@16
|
98 <const value_type>::type const_reference;
|
Chris@16
|
99 typedef typename segment_manager::size_type size_type;
|
Chris@16
|
100 typedef typename segment_manager::size_type difference_type;
|
Chris@16
|
101 typedef boost::interprocess::version_type
|
Chris@16
|
102 <private_adaptive_pool_base, Version> version;
|
Chris@16
|
103 typedef boost::container::container_detail::transform_multiallocation_chain
|
Chris@16
|
104 <typename SegmentManager::multiallocation_chain, T>multiallocation_chain;
|
Chris@16
|
105
|
Chris@16
|
106 //!Obtains node_allocator from other node_allocator
|
Chris@16
|
107 template<class T2>
|
Chris@16
|
108 struct rebind
|
Chris@16
|
109 {
|
Chris@16
|
110 typedef private_adaptive_pool_base
|
Chris@16
|
111 <Version, T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
Chris@16
|
112 };
|
Chris@16
|
113
|
Chris@101
|
114 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
Chris@16
|
115
|
Chris@16
|
116 template <int dummy>
|
Chris@16
|
117 struct node_pool
|
Chris@16
|
118 {
|
Chris@16
|
119 typedef ipcdetail::private_adaptive_node_pool
|
Chris@16
|
120 <SegmentManager
|
Chris@16
|
121 , sizeof_value<T>::value
|
Chris@16
|
122 , NodesPerBlock
|
Chris@16
|
123 , MaxFreeBlocks
|
Chris@16
|
124 , OverheadPercent
|
Chris@16
|
125 > type;
|
Chris@16
|
126
|
Chris@16
|
127 static type *get(void *p)
|
Chris@16
|
128 { return static_cast<type*>(p); }
|
Chris@16
|
129 };
|
Chris@16
|
130
|
Chris@16
|
131 private:
|
Chris@16
|
132 //!Not assignable from related private_adaptive_pool_base
|
Chris@16
|
133 template<unsigned int Version2, class T2, class MemoryAlgorithm2, std::size_t N2, std::size_t F2, unsigned char OP2>
|
Chris@16
|
134 private_adaptive_pool_base& operator=
|
Chris@16
|
135 (const private_adaptive_pool_base<Version2, T2, MemoryAlgorithm2, N2, F2, OP2>&);
|
Chris@16
|
136
|
Chris@16
|
137 //!Not assignable from other private_adaptive_pool_base
|
Chris@16
|
138 private_adaptive_pool_base& operator=(const private_adaptive_pool_base&);
|
Chris@101
|
139 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
140
|
Chris@16
|
141 public:
|
Chris@16
|
142 //!Constructor from a segment manager
|
Chris@16
|
143 private_adaptive_pool_base(segment_manager *segment_mngr)
|
Chris@16
|
144 : m_node_pool(segment_mngr)
|
Chris@16
|
145 {}
|
Chris@16
|
146
|
Chris@16
|
147 //!Copy constructor from other private_adaptive_pool_base. Never throws
|
Chris@16
|
148 private_adaptive_pool_base(const private_adaptive_pool_base &other)
|
Chris@16
|
149 : m_node_pool(other.get_segment_manager())
|
Chris@16
|
150 {}
|
Chris@16
|
151
|
Chris@16
|
152 //!Copy constructor from related private_adaptive_pool_base. Never throws.
|
Chris@16
|
153 template<class T2>
|
Chris@16
|
154 private_adaptive_pool_base
|
Chris@16
|
155 (const private_adaptive_pool_base
|
Chris@16
|
156 <Version, T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> &other)
|
Chris@16
|
157 : m_node_pool(other.get_segment_manager())
|
Chris@16
|
158 {}
|
Chris@16
|
159
|
Chris@16
|
160 //!Destructor, frees all used memory. Never throws
|
Chris@16
|
161 ~private_adaptive_pool_base()
|
Chris@16
|
162 {}
|
Chris@16
|
163
|
Chris@16
|
164 //!Returns the segment manager. Never throws
|
Chris@16
|
165 segment_manager* get_segment_manager()const
|
Chris@16
|
166 { return m_node_pool.get_segment_manager(); }
|
Chris@16
|
167
|
Chris@16
|
168 //!Returns the internal node pool. Never throws
|
Chris@16
|
169 node_pool_t* get_node_pool() const
|
Chris@16
|
170 { return const_cast<node_pool_t*>(&m_node_pool); }
|
Chris@16
|
171
|
Chris@16
|
172 //!Swaps allocators. Does not throw. If each allocator is placed in a
|
Chris@16
|
173 //!different shared memory segments, the result is undefined.
|
Chris@16
|
174 friend void swap(self_t &alloc1,self_t &alloc2)
|
Chris@101
|
175 { boost::adl_move_swap(alloc1.m_node_pool, alloc2.m_node_pool); }
|
Chris@16
|
176
|
Chris@101
|
177 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
Chris@16
|
178 private:
|
Chris@16
|
179 node_pool_t m_node_pool;
|
Chris@101
|
180 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
181 };
|
Chris@16
|
182
|
Chris@16
|
183 //!Equality test for same type of private_adaptive_pool_base
|
Chris@16
|
184 template<unsigned int V, class T, class S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> inline
|
Chris@16
|
185 bool operator==(const private_adaptive_pool_base<V, T, S, NodesPerBlock, F, OP> &alloc1,
|
Chris@16
|
186 const private_adaptive_pool_base<V, T, S, NodesPerBlock, F, OP> &alloc2)
|
Chris@16
|
187 { return &alloc1 == &alloc2; }
|
Chris@16
|
188
|
Chris@16
|
189 //!Inequality test for same type of private_adaptive_pool_base
|
Chris@16
|
190 template<unsigned int V, class T, class S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> inline
|
Chris@16
|
191 bool operator!=(const private_adaptive_pool_base<V, T, S, NodesPerBlock, F, OP> &alloc1,
|
Chris@16
|
192 const private_adaptive_pool_base<V, T, S, NodesPerBlock, F, OP> &alloc2)
|
Chris@16
|
193 { return &alloc1 != &alloc2; }
|
Chris@16
|
194
|
Chris@16
|
195 template < class T
|
Chris@16
|
196 , class SegmentManager
|
Chris@16
|
197 , std::size_t NodesPerBlock = 64
|
Chris@16
|
198 , std::size_t MaxFreeBlocks = 2
|
Chris@16
|
199 , unsigned char OverheadPercent = 5
|
Chris@16
|
200 >
|
Chris@16
|
201 class private_adaptive_pool_v1
|
Chris@16
|
202 : public private_adaptive_pool_base
|
Chris@16
|
203 < 1
|
Chris@16
|
204 , T
|
Chris@16
|
205 , SegmentManager
|
Chris@16
|
206 , NodesPerBlock
|
Chris@16
|
207 , MaxFreeBlocks
|
Chris@16
|
208 , OverheadPercent
|
Chris@16
|
209 >
|
Chris@16
|
210 {
|
Chris@16
|
211 public:
|
Chris@16
|
212 typedef ipcdetail::private_adaptive_pool_base
|
Chris@16
|
213 < 1, T, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> base_t;
|
Chris@16
|
214
|
Chris@16
|
215 template<class T2>
|
Chris@16
|
216 struct rebind
|
Chris@16
|
217 {
|
Chris@16
|
218 typedef private_adaptive_pool_v1<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
Chris@16
|
219 };
|
Chris@16
|
220
|
Chris@16
|
221 private_adaptive_pool_v1(SegmentManager *segment_mngr)
|
Chris@16
|
222 : base_t(segment_mngr)
|
Chris@16
|
223 {}
|
Chris@16
|
224
|
Chris@16
|
225 template<class T2>
|
Chris@16
|
226 private_adaptive_pool_v1
|
Chris@16
|
227 (const private_adaptive_pool_v1<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> &other)
|
Chris@16
|
228 : base_t(other)
|
Chris@16
|
229 {}
|
Chris@16
|
230 };
|
Chris@16
|
231
|
Chris@16
|
232 } //namespace ipcdetail {
|
Chris@16
|
233
|
Chris@101
|
234 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
235
|
Chris@16
|
236 //!An STL node allocator that uses a segment manager as memory
|
Chris@16
|
237 //!source. The internal pointer type will of the same type (raw, smart) as
|
Chris@16
|
238 //!"typename SegmentManager::void_pointer" type. This allows
|
Chris@16
|
239 //!placing the allocator in shared memory, memory mapped-files, etc...
|
Chris@16
|
240 //!This allocator has its own node pool.
|
Chris@16
|
241 //!
|
Chris@16
|
242 //!NodesPerBlock is the minimum number of nodes of nodes allocated at once when
|
Chris@16
|
243 //!the allocator needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks
|
Chris@16
|
244 //!that the adaptive node pool will hold. The rest of the totally free blocks will be
|
Chris@16
|
245 //!deallocated with the segment manager.
|
Chris@16
|
246 //!
|
Chris@16
|
247 //!OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator:
|
Chris@16
|
248 //!(memory usable for nodes / total memory allocated from the segment manager)
|
Chris@16
|
249 template < class T
|
Chris@16
|
250 , class SegmentManager
|
Chris@16
|
251 , std::size_t NodesPerBlock
|
Chris@16
|
252 , std::size_t MaxFreeBlocks
|
Chris@16
|
253 , unsigned char OverheadPercent
|
Chris@16
|
254 >
|
Chris@16
|
255 class private_adaptive_pool
|
Chris@101
|
256 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
|
Chris@16
|
257 : public ipcdetail::private_adaptive_pool_base
|
Chris@16
|
258 < 2
|
Chris@16
|
259 , T
|
Chris@16
|
260 , SegmentManager
|
Chris@16
|
261 , NodesPerBlock
|
Chris@16
|
262 , MaxFreeBlocks
|
Chris@16
|
263 , OverheadPercent
|
Chris@16
|
264 >
|
Chris@101
|
265 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
266 {
|
Chris@16
|
267
|
Chris@16
|
268 #ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
269 typedef ipcdetail::private_adaptive_pool_base
|
Chris@16
|
270 < 2, T, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> base_t;
|
Chris@16
|
271 public:
|
Chris@16
|
272 typedef boost::interprocess::version_type<private_adaptive_pool, 2> version;
|
Chris@16
|
273
|
Chris@16
|
274 template<class T2>
|
Chris@16
|
275 struct rebind
|
Chris@16
|
276 {
|
Chris@16
|
277 typedef private_adaptive_pool
|
Chris@16
|
278 <T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
Chris@16
|
279 };
|
Chris@16
|
280
|
Chris@16
|
281 private_adaptive_pool(SegmentManager *segment_mngr)
|
Chris@16
|
282 : base_t(segment_mngr)
|
Chris@16
|
283 {}
|
Chris@16
|
284
|
Chris@16
|
285 template<class T2>
|
Chris@16
|
286 private_adaptive_pool
|
Chris@16
|
287 (const private_adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> &other)
|
Chris@16
|
288 : base_t(other)
|
Chris@16
|
289 {}
|
Chris@16
|
290
|
Chris@16
|
291 #else
|
Chris@16
|
292 public:
|
Chris@16
|
293 typedef implementation_defined::segment_manager segment_manager;
|
Chris@16
|
294 typedef segment_manager::void_pointer void_pointer;
|
Chris@16
|
295 typedef implementation_defined::pointer pointer;
|
Chris@16
|
296 typedef implementation_defined::const_pointer const_pointer;
|
Chris@16
|
297 typedef T value_type;
|
Chris@16
|
298 typedef typename ipcdetail::add_reference
|
Chris@16
|
299 <value_type>::type reference;
|
Chris@16
|
300 typedef typename ipcdetail::add_reference
|
Chris@16
|
301 <const value_type>::type const_reference;
|
Chris@16
|
302 typedef typename segment_manager::size_type size_type;
|
Chris@16
|
303 typedef typename segment_manager::difference_type difference_type;
|
Chris@16
|
304
|
Chris@16
|
305 //!Obtains private_adaptive_pool from
|
Chris@16
|
306 //!private_adaptive_pool
|
Chris@16
|
307 template<class T2>
|
Chris@16
|
308 struct rebind
|
Chris@16
|
309 {
|
Chris@16
|
310 typedef private_adaptive_pool
|
Chris@16
|
311 <T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> other;
|
Chris@16
|
312 };
|
Chris@16
|
313
|
Chris@16
|
314 private:
|
Chris@16
|
315 //!Not assignable from
|
Chris@16
|
316 //!related private_adaptive_pool
|
Chris@16
|
317 template<class T2, class SegmentManager2, std::size_t N2, std::size_t F2, unsigned char OP2>
|
Chris@16
|
318 private_adaptive_pool& operator=
|
Chris@16
|
319 (const private_adaptive_pool<T2, SegmentManager2, N2, F2>&);
|
Chris@16
|
320
|
Chris@16
|
321 //!Not assignable from
|
Chris@16
|
322 //!other private_adaptive_pool
|
Chris@16
|
323 private_adaptive_pool& operator=(const private_adaptive_pool&);
|
Chris@16
|
324
|
Chris@16
|
325 public:
|
Chris@16
|
326 //!Constructor from a segment manager. If not present, constructs a node
|
Chris@16
|
327 //!pool. Increments the reference count of the associated node pool.
|
Chris@16
|
328 //!Can throw boost::interprocess::bad_alloc
|
Chris@16
|
329 private_adaptive_pool(segment_manager *segment_mngr);
|
Chris@16
|
330
|
Chris@16
|
331 //!Copy constructor from other private_adaptive_pool. Increments the reference
|
Chris@16
|
332 //!count of the associated node pool. Never throws
|
Chris@16
|
333 private_adaptive_pool(const private_adaptive_pool &other);
|
Chris@16
|
334
|
Chris@16
|
335 //!Copy constructor from related private_adaptive_pool. If not present, constructs
|
Chris@16
|
336 //!a node pool. Increments the reference count of the associated node pool.
|
Chris@16
|
337 //!Can throw boost::interprocess::bad_alloc
|
Chris@16
|
338 template<class T2>
|
Chris@16
|
339 private_adaptive_pool
|
Chris@16
|
340 (const private_adaptive_pool<T2, SegmentManager, NodesPerBlock, MaxFreeBlocks, OverheadPercent> &other);
|
Chris@16
|
341
|
Chris@16
|
342 //!Destructor, removes node_pool_t from memory
|
Chris@16
|
343 //!if its reference count reaches to zero. Never throws
|
Chris@16
|
344 ~private_adaptive_pool();
|
Chris@16
|
345
|
Chris@16
|
346 //!Returns a pointer to the node pool.
|
Chris@16
|
347 //!Never throws
|
Chris@16
|
348 node_pool_t* get_node_pool() const;
|
Chris@16
|
349
|
Chris@16
|
350 //!Returns the segment manager.
|
Chris@16
|
351 //!Never throws
|
Chris@16
|
352 segment_manager* get_segment_manager()const;
|
Chris@16
|
353
|
Chris@16
|
354 //!Returns the number of elements that could be allocated.
|
Chris@16
|
355 //!Never throws
|
Chris@16
|
356 size_type max_size() const;
|
Chris@16
|
357
|
Chris@16
|
358 //!Allocate memory for an array of count elements.
|
Chris@16
|
359 //!Throws boost::interprocess::bad_alloc if there is no enough memory
|
Chris@16
|
360 pointer allocate(size_type count, cvoid_pointer hint = 0);
|
Chris@16
|
361
|
Chris@16
|
362 //!Deallocate allocated memory.
|
Chris@16
|
363 //!Never throws
|
Chris@16
|
364 void deallocate(const pointer &ptr, size_type count);
|
Chris@16
|
365
|
Chris@16
|
366 //!Deallocates all free blocks
|
Chris@16
|
367 //!of the pool
|
Chris@16
|
368 void deallocate_free_blocks();
|
Chris@16
|
369
|
Chris@16
|
370 //!Swaps allocators. Does not throw. If each allocator is placed in a
|
Chris@16
|
371 //!different memory segment, the result is undefined.
|
Chris@16
|
372 friend void swap(self_t &alloc1, self_t &alloc2);
|
Chris@16
|
373
|
Chris@16
|
374 //!Returns address of mutable object.
|
Chris@16
|
375 //!Never throws
|
Chris@16
|
376 pointer address(reference value) const;
|
Chris@16
|
377
|
Chris@16
|
378 //!Returns address of non mutable object.
|
Chris@16
|
379 //!Never throws
|
Chris@16
|
380 const_pointer address(const_reference value) const;
|
Chris@16
|
381
|
Chris@16
|
382 //!Copy construct an object.
|
Chris@16
|
383 //!Throws if T's copy constructor throws
|
Chris@16
|
384 void construct(const pointer &ptr, const_reference v);
|
Chris@16
|
385
|
Chris@16
|
386 //!Destroys object. Throws if object's
|
Chris@16
|
387 //!destructor throws
|
Chris@16
|
388 void destroy(const pointer &ptr);
|
Chris@16
|
389
|
Chris@16
|
390 //!Returns maximum the number of objects the previously allocated memory
|
Chris@16
|
391 //!pointed by p can hold. This size only works for memory allocated with
|
Chris@16
|
392 //!allocate, allocation_command and allocate_many.
|
Chris@16
|
393 size_type size(const pointer &p) const;
|
Chris@16
|
394
|
Chris@101
|
395 pointer allocation_command(boost::interprocess::allocation_type command,
|
Chris@101
|
396 size_type limit_size, size_type &prefer_in_recvd_out_size, pointer &reuse);
|
Chris@16
|
397
|
Chris@16
|
398 //!Allocates many elements of size elem_size in a contiguous block
|
Chris@16
|
399 //!of memory. The minimum number to be allocated is min_elements,
|
Chris@16
|
400 //!the preferred and maximum number is
|
Chris@16
|
401 //!preferred_elements. The number of actually allocated elements is
|
Chris@16
|
402 //!will be assigned to received_size. The elements must be deallocated
|
Chris@16
|
403 //!with deallocate(...)
|
Chris@16
|
404 void allocate_many(size_type elem_size, size_type num_elements, multiallocation_chain &chain);
|
Chris@16
|
405
|
Chris@16
|
406 //!Allocates n_elements elements, each one of size elem_sizes[i]in a
|
Chris@16
|
407 //!contiguous block
|
Chris@16
|
408 //!of memory. The elements must be deallocated
|
Chris@16
|
409 void allocate_many(const size_type *elem_sizes, size_type n_elements, multiallocation_chain &chain);
|
Chris@16
|
410
|
Chris@16
|
411 //!Allocates many elements of size elem_size in a contiguous block
|
Chris@16
|
412 //!of memory. The minimum number to be allocated is min_elements,
|
Chris@16
|
413 //!the preferred and maximum number is
|
Chris@16
|
414 //!preferred_elements. The number of actually allocated elements is
|
Chris@16
|
415 //!will be assigned to received_size. The elements must be deallocated
|
Chris@16
|
416 //!with deallocate(...)
|
Chris@16
|
417 void deallocate_many(multiallocation_chain &chain);
|
Chris@16
|
418
|
Chris@16
|
419 //!Allocates just one object. Memory allocated with this function
|
Chris@16
|
420 //!must be deallocated only with deallocate_one().
|
Chris@16
|
421 //!Throws boost::interprocess::bad_alloc if there is no enough memory
|
Chris@16
|
422 pointer allocate_one();
|
Chris@16
|
423
|
Chris@16
|
424 //!Allocates many elements of size == 1 in a contiguous block
|
Chris@16
|
425 //!of memory. The minimum number to be allocated is min_elements,
|
Chris@16
|
426 //!the preferred and maximum number is
|
Chris@16
|
427 //!preferred_elements. The number of actually allocated elements is
|
Chris@16
|
428 //!will be assigned to received_size. Memory allocated with this function
|
Chris@16
|
429 //!must be deallocated only with deallocate_one().
|
Chris@16
|
430 void allocate_individual(size_type num_elements, multiallocation_chain &chain);
|
Chris@16
|
431
|
Chris@16
|
432 //!Deallocates memory previously allocated with allocate_one().
|
Chris@16
|
433 //!You should never use deallocate_one to deallocate memory allocated
|
Chris@16
|
434 //!with other functions different from allocate_one(). Never throws
|
Chris@16
|
435 void deallocate_one(const pointer &p);
|
Chris@16
|
436
|
Chris@16
|
437 //!Allocates many elements of size == 1 in a contiguous block
|
Chris@16
|
438 //!of memory. The minimum number to be allocated is min_elements,
|
Chris@16
|
439 //!the preferred and maximum number is
|
Chris@16
|
440 //!preferred_elements. The number of actually allocated elements is
|
Chris@16
|
441 //!will be assigned to received_size. Memory allocated with this function
|
Chris@16
|
442 //!must be deallocated only with deallocate_one().
|
Chris@16
|
443 void deallocate_individual(multiallocation_chain &chain);
|
Chris@16
|
444 #endif
|
Chris@16
|
445 };
|
Chris@16
|
446
|
Chris@16
|
447 #ifdef BOOST_INTERPROCESS_DOXYGEN_INVOKED
|
Chris@16
|
448
|
Chris@16
|
449 //!Equality test for same type
|
Chris@16
|
450 //!of private_adaptive_pool
|
Chris@16
|
451 template<class T, class S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> inline
|
Chris@16
|
452 bool operator==(const private_adaptive_pool<T, S, NodesPerBlock, F, OP> &alloc1,
|
Chris@16
|
453 const private_adaptive_pool<T, S, NodesPerBlock, F, OP> &alloc2);
|
Chris@16
|
454
|
Chris@16
|
455 //!Inequality test for same type
|
Chris@16
|
456 //!of private_adaptive_pool
|
Chris@16
|
457 template<class T, class S, std::size_t NodesPerBlock, std::size_t F, unsigned char OP> inline
|
Chris@16
|
458 bool operator!=(const private_adaptive_pool<T, S, NodesPerBlock, F, OP> &alloc1,
|
Chris@16
|
459 const private_adaptive_pool<T, S, NodesPerBlock, F, OP> &alloc2);
|
Chris@16
|
460
|
Chris@16
|
461 #endif
|
Chris@16
|
462
|
Chris@16
|
463 } //namespace interprocess {
|
Chris@16
|
464 } //namespace boost {
|
Chris@16
|
465
|
Chris@16
|
466 #include <boost/interprocess/detail/config_end.hpp>
|
Chris@16
|
467
|
Chris@16
|
468 #endif //#ifndef BOOST_INTERPROCESS_PRIVATE_ADAPTIVE_POOL_HPP
|
Chris@16
|
469
|