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_DETAIL_NODE_POOL_HPP
|
Chris@16
|
12 #define BOOST_INTERPROCESS_DETAIL_NODE_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/slist.hpp>
|
Chris@16
|
26 #include <boost/interprocess/detail/utilities.hpp>
|
Chris@16
|
27 #include <boost/interprocess/allocators/detail/allocator_common.hpp>
|
Chris@16
|
28 #include <boost/container/detail/node_pool_impl.hpp>
|
Chris@16
|
29 #include <cstddef>
|
Chris@16
|
30
|
Chris@16
|
31
|
Chris@16
|
32 //!\file
|
Chris@16
|
33 //!Describes the real adaptive pool shared by many Interprocess adaptive pool allocators
|
Chris@16
|
34
|
Chris@16
|
35 namespace boost {
|
Chris@16
|
36 namespace interprocess {
|
Chris@16
|
37 namespace ipcdetail {
|
Chris@16
|
38
|
Chris@16
|
39
|
Chris@16
|
40
|
Chris@16
|
41 //!Pooled shared memory allocator using single segregated storage. Includes
|
Chris@16
|
42 //!a reference count but the class does not delete itself, this is
|
Chris@16
|
43 //!responsibility of user classes. Node size (NodeSize) and the number of
|
Chris@16
|
44 //!nodes allocated per block (NodesPerBlock) are known at compile time
|
Chris@16
|
45 template< class SegmentManager, std::size_t NodeSize, std::size_t NodesPerBlock >
|
Chris@16
|
46 class private_node_pool
|
Chris@16
|
47 //Inherit from the implementation to avoid template bloat
|
Chris@16
|
48 : public boost::container::container_detail::
|
Chris@16
|
49 private_node_pool_impl<typename SegmentManager::segment_manager_base_type>
|
Chris@16
|
50 {
|
Chris@16
|
51 typedef boost::container::container_detail::private_node_pool_impl
|
Chris@16
|
52 <typename SegmentManager::segment_manager_base_type> base_t;
|
Chris@16
|
53 //Non-copyable
|
Chris@16
|
54 private_node_pool();
|
Chris@16
|
55 private_node_pool(const private_node_pool &);
|
Chris@16
|
56 private_node_pool &operator=(const private_node_pool &);
|
Chris@16
|
57
|
Chris@16
|
58 public:
|
Chris@16
|
59 typedef SegmentManager segment_manager;
|
Chris@16
|
60 typedef typename base_t::size_type size_type;
|
Chris@16
|
61
|
Chris@16
|
62 static const size_type nodes_per_block = NodesPerBlock;
|
Chris@16
|
63 //Deprecated, use nodes_per_block
|
Chris@16
|
64 static const size_type nodes_per_chunk = NodesPerBlock;
|
Chris@16
|
65
|
Chris@16
|
66 //!Constructor from a segment manager. Never throws
|
Chris@16
|
67 private_node_pool(segment_manager *segment_mngr)
|
Chris@16
|
68 : base_t(segment_mngr, NodeSize, NodesPerBlock)
|
Chris@16
|
69 {}
|
Chris@16
|
70
|
Chris@16
|
71 //!Returns the segment manager. Never throws
|
Chris@16
|
72 segment_manager* get_segment_manager() const
|
Chris@16
|
73 { return static_cast<segment_manager*>(base_t::get_segment_manager_base()); }
|
Chris@16
|
74 };
|
Chris@16
|
75
|
Chris@16
|
76
|
Chris@16
|
77 //!Pooled shared memory allocator using single segregated storage. Includes
|
Chris@16
|
78 //!a reference count but the class does not delete itself, this is
|
Chris@16
|
79 //!responsibility of user classes. Node size (NodeSize) and the number of
|
Chris@16
|
80 //!nodes allocated per block (NodesPerBlock) are known at compile time
|
Chris@16
|
81 //!Pooled shared memory allocator using adaptive pool. Includes
|
Chris@16
|
82 //!a reference count but the class does not delete itself, this is
|
Chris@16
|
83 //!responsibility of user classes. Node size (NodeSize) and the number of
|
Chris@16
|
84 //!nodes allocated per block (NodesPerBlock) are known at compile time
|
Chris@16
|
85 template< class SegmentManager
|
Chris@16
|
86 , std::size_t NodeSize
|
Chris@16
|
87 , std::size_t NodesPerBlock
|
Chris@16
|
88 >
|
Chris@16
|
89 class shared_node_pool
|
Chris@16
|
90 : public ipcdetail::shared_pool_impl
|
Chris@16
|
91 < private_node_pool
|
Chris@16
|
92 <SegmentManager, NodeSize, NodesPerBlock>
|
Chris@16
|
93 >
|
Chris@16
|
94 {
|
Chris@16
|
95 typedef ipcdetail::shared_pool_impl
|
Chris@16
|
96 < private_node_pool
|
Chris@16
|
97 <SegmentManager, NodeSize, NodesPerBlock>
|
Chris@16
|
98 > base_t;
|
Chris@16
|
99 public:
|
Chris@16
|
100 shared_node_pool(SegmentManager *segment_mgnr)
|
Chris@16
|
101 : base_t(segment_mgnr)
|
Chris@16
|
102 {}
|
Chris@16
|
103 };
|
Chris@16
|
104
|
Chris@16
|
105 } //namespace ipcdetail {
|
Chris@16
|
106 } //namespace interprocess {
|
Chris@16
|
107 } //namespace boost {
|
Chris@16
|
108
|
Chris@16
|
109 #include <boost/interprocess/detail/config_end.hpp>
|
Chris@16
|
110
|
Chris@16
|
111 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_NODE_POOL_HPP
|