1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP
12 #define BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #include <boost/interprocess/detail/config_begin.hpp>
23 #include <boost/interprocess/detail/workaround.hpp>
24 #include <boost/interprocess/detail/utilities.hpp>
25 #include <boost/interprocess/detail/math_functions.hpp>
26 #include <boost/intrusive/set.hpp>
27 #include <boost/intrusive/slist.hpp>
28 #include <boost/interprocess/detail/type_traits.hpp>
29 #include <boost/interprocess/mem_algo/detail/mem_algo_common.hpp>
30 #include <boost/interprocess/allocators/detail/node_tools.hpp>
31 #include <boost/interprocess/allocators/detail/allocator_common.hpp>
33 #include <boost/config/no_tr1/cmath.hpp>
34 #include <boost/container/detail/adaptive_node_pool_impl.hpp>
35 #include <boost/assert.hpp>
38 //!Describes the real adaptive pool shared by many Interprocess pool allocators
41 namespace interprocess {
44 template< class SegmentManager
45 , std::size_t NodeSize
46 , std::size_t NodesPerBlock
47 , std::size_t MaxFreeBlocks
48 , unsigned char OverheadPercent
50 class private_adaptive_node_pool
51 : public boost::container::dtl::private_adaptive_node_pool_impl_rt
52 < typename SegmentManager::segment_manager_base_type
53 , ::boost::container::adaptive_pool_flag::size_ordered |
54 ::boost::container::adaptive_pool_flag::address_ordered
57 typedef boost::container::dtl::private_adaptive_node_pool_impl_rt
58 < typename SegmentManager::segment_manager_base_type
59 , ::boost::container::adaptive_pool_flag::size_ordered |
60 ::boost::container::adaptive_pool_flag::address_ordered
63 private_adaptive_node_pool();
64 private_adaptive_node_pool(const private_adaptive_node_pool &);
65 private_adaptive_node_pool &operator=(const private_adaptive_node_pool &);
68 typedef SegmentManager segment_manager;
69 typedef typename base_t::size_type size_type;
71 static const size_type nodes_per_block = NodesPerBlock;
73 //!Constructor from a segment manager. Never throws
74 private_adaptive_node_pool(segment_manager *segment_mngr)
75 : base_t(segment_mngr, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent)
78 //!Returns the segment manager. Never throws
79 segment_manager* get_segment_manager() const
80 { return static_cast<segment_manager*>(base_t::get_segment_manager_base()); }
83 //!Pooled shared memory allocator using adaptive pool. Includes
84 //!a reference count but the class does not delete itself, this is
85 //!responsibility of user classes. Node size (NodeSize) and the number of
86 //!nodes allocated per block (NodesPerBlock) are known at compile time
87 template< class SegmentManager
88 , std::size_t NodeSize
89 , std::size_t NodesPerBlock
90 , std::size_t MaxFreeBlocks
91 , unsigned char OverheadPercent
93 class shared_adaptive_node_pool
94 : public ipcdetail::shared_pool_impl
95 < private_adaptive_node_pool
96 <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
99 typedef ipcdetail::shared_pool_impl
100 < private_adaptive_node_pool
101 <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
104 shared_adaptive_node_pool(SegmentManager *segment_mgnr)
105 : base_t(segment_mgnr)
109 } //namespace ipcdetail {
110 } //namespace interprocess {
111 } //namespace boost {
113 #include <boost/interprocess/detail/config_end.hpp>
115 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP