]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/interprocess/allocators/detail/adaptive_node_pool.hpp
update sources to v12.2.3
[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::container_detail::private_adaptive_node_pool_impl
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::container_detail::private_adaptive_node_pool_impl
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 //Deprecated, use node_per_block
74 static const size_type nodes_per_chunk = NodesPerBlock;
75
76 //!Constructor from a segment manager. Never throws
77 private_adaptive_node_pool(segment_manager *segment_mngr)
78 : base_t(segment_mngr, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent)
79 {}
80
81 //!Returns the segment manager. Never throws
82 segment_manager* get_segment_manager() const
83 { return static_cast<segment_manager*>(base_t::get_segment_manager_base()); }
84 };
85
86 //!Pooled shared memory allocator using adaptive pool. Includes
87 //!a reference count but the class does not delete itself, this is
88 //!responsibility of user classes. Node size (NodeSize) and the number of
89 //!nodes allocated per block (NodesPerBlock) are known at compile time
90 template< class SegmentManager
91 , std::size_t NodeSize
92 , std::size_t NodesPerBlock
93 , std::size_t MaxFreeBlocks
94 , unsigned char OverheadPercent
95 >
96 class shared_adaptive_node_pool
97 : public ipcdetail::shared_pool_impl
98 < private_adaptive_node_pool
99 <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
100 >
101 {
102 typedef ipcdetail::shared_pool_impl
103 < private_adaptive_node_pool
104 <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
105 > base_t;
106 public:
107 shared_adaptive_node_pool(SegmentManager *segment_mgnr)
108 : base_t(segment_mgnr)
109 {}
110 };
111
112 } //namespace ipcdetail {
113 } //namespace interprocess {
114 } //namespace boost {
115
116 #include <boost/interprocess/detail/config_end.hpp>
117
118 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP