Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:24

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP
0012 #define BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 #  pragma once
0020 #endif
0021 
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 #include <boost/interprocess/detail/utilities.hpp>
0025 #include <boost/interprocess/detail/math_functions.hpp>
0026 #include <boost/intrusive/set.hpp>
0027 #include <boost/intrusive/slist.hpp>
0028 #include <boost/interprocess/detail/type_traits.hpp>
0029 #include <boost/interprocess/mem_algo/detail/mem_algo_common.hpp>
0030 #include <boost/interprocess/allocators/detail/node_tools.hpp>
0031 #include <boost/interprocess/allocators/detail/allocator_common.hpp>
0032 #include <cstddef>
0033 #include <boost/config/no_tr1/cmath.hpp>
0034 #include <boost/container/detail/adaptive_node_pool_impl.hpp>
0035 #include <boost/assert.hpp>
0036 
0037 //!\file
0038 //!Describes the real adaptive pool shared by many Interprocess pool allocators
0039 
0040 namespace boost {
0041 namespace interprocess {
0042 namespace ipcdetail {
0043 
0044 template< class SegmentManager
0045         , std::size_t NodeSize
0046         , std::size_t NodesPerBlock
0047         , std::size_t MaxFreeBlocks
0048         , unsigned char OverheadPercent
0049         >
0050 class private_adaptive_node_pool
0051    :  public boost::container::dtl::private_adaptive_node_pool_impl_rt
0052          < typename SegmentManager::segment_manager_base_type
0053          , ::boost::container::adaptive_pool_flag::size_ordered |
0054            ::boost::container::adaptive_pool_flag::address_ordered
0055          >
0056 {
0057    typedef boost::container::dtl::private_adaptive_node_pool_impl_rt
0058       < typename SegmentManager::segment_manager_base_type
0059       , ::boost::container::adaptive_pool_flag::size_ordered |
0060         ::boost::container::adaptive_pool_flag::address_ordered
0061       > base_t;
0062    //Non-copyable
0063    private_adaptive_node_pool();
0064    private_adaptive_node_pool(const private_adaptive_node_pool &);
0065    private_adaptive_node_pool &operator=(const private_adaptive_node_pool &);
0066 
0067    public:
0068    typedef SegmentManager              segment_manager;
0069    typedef typename base_t::size_type  size_type;
0070 
0071    static const size_type nodes_per_block = NodesPerBlock;
0072 
0073    //!Constructor from a segment manager. Never throws
0074    private_adaptive_node_pool(segment_manager *segment_mngr)
0075       :  base_t(segment_mngr, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent)
0076    {}
0077 
0078    //!Returns the segment manager. Never throws
0079    segment_manager* get_segment_manager() const
0080    {  return static_cast<segment_manager*>(base_t::get_segment_manager_base()); }
0081 };
0082 
0083 //!Pooled shared memory allocator using adaptive pool. Includes
0084 //!a reference count but the class does not delete itself, this is
0085 //!responsibility of user classes. Node size (NodeSize) and the number of
0086 //!nodes allocated per block (NodesPerBlock) are known at compile time
0087 template< class SegmentManager
0088         , std::size_t NodeSize
0089         , std::size_t NodesPerBlock
0090         , std::size_t MaxFreeBlocks
0091         , unsigned char OverheadPercent
0092         >
0093 class shared_adaptive_node_pool
0094    :  public ipcdetail::shared_pool_impl
0095       < private_adaptive_node_pool
0096          <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
0097       >
0098 {
0099    typedef ipcdetail::shared_pool_impl
0100       < private_adaptive_node_pool
0101          <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
0102       > base_t;
0103    public:
0104    shared_adaptive_node_pool(SegmentManager *segment_mgnr)
0105       : base_t(segment_mgnr)
0106    {}
0107 };
0108 
0109 }  //namespace ipcdetail {
0110 }  //namespace interprocess {
0111 }  //namespace boost {
0112 
0113 #include <boost/interprocess/detail/config_end.hpp>
0114 
0115 #endif   //#ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP