]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/interprocess/allocators/detail/adaptive_node_pool.hpp
e9a8e2655cf79091f44cee80717ad6f390de42a5
[ceph.git] / ceph / src / boost / boost / interprocess / allocators / detail / adaptive_node_pool.hpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
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)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10
11 #ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP
12 #define BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP
13
14 #ifndef BOOST_CONFIG_HPP
15 # include <boost/config.hpp>
16 #endif
17 #
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
19 # pragma once
20 #endif
21
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>
32 #include <cstddef>
33 #include <boost/config/no_tr1/cmath.hpp>
34 #include <boost/container/detail/adaptive_node_pool_impl.hpp>
35 #include <boost/assert.hpp>
36
37 //!\file
38 //!Describes the real adaptive pool shared by many Interprocess pool allocators
39
40 namespace boost {
41 namespace interprocess {
42 namespace ipcdetail {
43
44 template< class SegmentManager
45 , std::size_t NodeSize
46 , std::size_t NodesPerBlock
47 , std::size_t MaxFreeBlocks
48 , unsigned char OverheadPercent
49 >
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
55 >
56 {
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
61 > base_t;
62 //Non-copyable
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 &);
66
67 public:
68 typedef SegmentManager segment_manager;
69 typedef typename base_t::size_type size_type;
70
71 static const size_type nodes_per_block = NodesPerBlock;
72
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)
76 {}
77
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()); }
81 };
82
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
92 >
93 class shared_adaptive_node_pool
94 : public ipcdetail::shared_pool_impl
95 < private_adaptive_node_pool
96 <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
97 >
98 {
99 typedef ipcdetail::shared_pool_impl
100 < private_adaptive_node_pool
101 <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
102 > base_t;
103 public:
104 shared_adaptive_node_pool(SegmentManager *segment_mgnr)
105 : base_t(segment_mgnr)
106 {}
107 };
108
109 } //namespace ipcdetail {
110 } //namespace interprocess {
111 } //namespace boost {
112
113 #include <boost/interprocess/detail/config_end.hpp>
114
115 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP