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_NODE_POOL_HPP
12 #define BOOST_INTERPROCESS_DETAIL_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>
25 #include <boost/intrusive/slist.hpp>
26 #include <boost/interprocess/detail/utilities.hpp>
27 #include <boost/interprocess/allocators/detail/allocator_common.hpp>
28 #include <boost/container/detail/node_pool_impl.hpp>
33 //!Describes the real adaptive pool shared by many Interprocess adaptive pool allocators
36 namespace interprocess {
41 //!Pooled shared memory allocator using single segregated storage. Includes
42 //!a reference count but the class does not delete itself, this is
43 //!responsibility of user classes. Node size (NodeSize) and the number of
44 //!nodes allocated per block (NodesPerBlock) are known at compile time
45 template< class SegmentManager, std::size_t NodeSize, std::size_t NodesPerBlock >
46 class private_node_pool
47 //Inherit from the implementation to avoid template bloat
48 : public boost::container::container_detail::
49 private_node_pool_impl<typename SegmentManager::segment_manager_base_type>
51 typedef boost::container::container_detail::private_node_pool_impl
52 <typename SegmentManager::segment_manager_base_type> base_t;
55 private_node_pool(const private_node_pool &);
56 private_node_pool &operator=(const private_node_pool &);
59 typedef SegmentManager segment_manager;
60 typedef typename base_t::size_type size_type;
62 static const size_type nodes_per_block = NodesPerBlock;
63 //Deprecated, use nodes_per_block
64 static const size_type nodes_per_chunk = NodesPerBlock;
66 //!Constructor from a segment manager. Never throws
67 private_node_pool(segment_manager *segment_mngr)
68 : base_t(segment_mngr, NodeSize, NodesPerBlock)
71 //!Returns the segment manager. Never throws
72 segment_manager* get_segment_manager() const
73 { return static_cast<segment_manager*>(base_t::get_segment_manager_base()); }
77 //!Pooled shared memory allocator using single segregated storage. Includes
78 //!a reference count but the class does not delete itself, this is
79 //!responsibility of user classes. Node size (NodeSize) and the number of
80 //!nodes allocated per block (NodesPerBlock) are known at compile time
81 //!Pooled shared memory allocator using adaptive pool. Includes
82 //!a reference count but the class does not delete itself, this is
83 //!responsibility of user classes. Node size (NodeSize) and the number of
84 //!nodes allocated per block (NodesPerBlock) are known at compile time
85 template< class SegmentManager
86 , std::size_t NodeSize
87 , std::size_t NodesPerBlock
89 class shared_node_pool
90 : public ipcdetail::shared_pool_impl
92 <SegmentManager, NodeSize, NodesPerBlock>
95 typedef ipcdetail::shared_pool_impl
97 <SegmentManager, NodeSize, NodesPerBlock>
100 shared_node_pool(SegmentManager *segment_mgnr)
101 : base_t(segment_mgnr)
105 } //namespace ipcdetail {
106 } //namespace interprocess {
107 } //namespace boost {
109 #include <boost/interprocess/detail/config_end.hpp>
111 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_NODE_POOL_HPP