PageRenderTime 34ms CodeModel.GetById 16ms app.highlight 12ms RepoModel.GetById 2ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/interprocess/allocators/detail/adaptive_node_pool.hpp

http://hadesmem.googlecode.com/
C++ Header | 108 lines | 74 code | 15 blank | 19 comment | 1 complexity | c1997080586d34b525572817b9513018 MD5 | raw file
  1//////////////////////////////////////////////////////////////////////////////
  2//
  3// (C) Copyright Ion Gaztanaga 2005-2009. 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#if (defined _MSC_VER) && (_MSC_VER >= 1200)
 15#  pragma once
 16#endif
 17
 18#include <boost/interprocess/detail/config_begin.hpp>
 19#include <boost/interprocess/detail/workaround.hpp>
 20#include <boost/pointer_to_other.hpp>
 21#include <boost/interprocess/detail/utilities.hpp>
 22#include <boost/interprocess/detail/math_functions.hpp>
 23#include <boost/intrusive/set.hpp>
 24#include <boost/intrusive/slist.hpp>
 25#include <boost/interprocess/detail/type_traits.hpp>
 26#include <boost/interprocess/mem_algo/detail/mem_algo_common.hpp>
 27#include <boost/interprocess/allocators/detail/node_tools.hpp>
 28#include <boost/interprocess/allocators/detail/allocator_common.hpp>
 29#include <cstddef>
 30#include <boost/config/no_tr1/cmath.hpp>
 31#include <boost/interprocess/containers/container/detail/adaptive_node_pool_impl.hpp>
 32#include <boost/assert.hpp>
 33
 34//!\file
 35//!Describes the real adaptive pool shared by many Interprocess pool allocators
 36
 37namespace boost {
 38namespace interprocess {
 39namespace detail {
 40
 41template< class SegmentManager
 42        , std::size_t NodeSize
 43        , std::size_t NodesPerBlock
 44        , std::size_t MaxFreeBlocks
 45        , unsigned char OverheadPercent
 46        >
 47class private_adaptive_node_pool
 48   :  public boost::container::containers_detail::private_adaptive_node_pool_impl
 49         <typename SegmentManager::segment_manager_base_type>
 50{
 51   typedef boost::container::containers_detail::private_adaptive_node_pool_impl
 52      <typename SegmentManager::segment_manager_base_type> base_t;
 53   //Non-copyable
 54   private_adaptive_node_pool();
 55   private_adaptive_node_pool(const private_adaptive_node_pool &);
 56   private_adaptive_node_pool &operator=(const private_adaptive_node_pool &);
 57
 58   public:
 59   typedef SegmentManager segment_manager;
 60
 61   static const std::size_t nodes_per_block = NodesPerBlock;
 62
 63   //Deprecated, use node_per_block
 64   static const std::size_t nodes_per_chunk = NodesPerBlock;
 65
 66   //!Constructor from a segment manager. Never throws
 67   private_adaptive_node_pool(segment_manager *segment_mngr)
 68      :  base_t(segment_mngr, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent)
 69   {}
 70
 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()); }
 74};
 75
 76//!Pooled shared memory allocator using adaptive pool. Includes
 77//!a reference count but the class does not delete itself, this is  
 78//!responsibility of user classes. Node size (NodeSize) and the number of
 79//!nodes allocated per block (NodesPerBlock) are known at compile time
 80template< class SegmentManager
 81        , std::size_t NodeSize
 82        , std::size_t NodesPerBlock
 83        , std::size_t MaxFreeBlocks
 84        , unsigned char OverheadPercent
 85        >
 86class shared_adaptive_node_pool 
 87   :  public detail::shared_pool_impl
 88      < private_adaptive_node_pool
 89         <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
 90      >
 91{
 92   typedef detail::shared_pool_impl
 93      < private_adaptive_node_pool
 94         <SegmentManager, NodeSize, NodesPerBlock, MaxFreeBlocks, OverheadPercent>
 95      > base_t;
 96   public:
 97   shared_adaptive_node_pool(SegmentManager *segment_mgnr)
 98      : base_t(segment_mgnr)
 99   {}
100};
101
102}  //namespace detail {
103}  //namespace interprocess {
104}  //namespace boost {
105
106#include <boost/interprocess/detail/config_end.hpp>
107
108#endif   //#ifndef BOOST_INTERPROCESS_DETAIL_ADAPTIVE_NODE_POOL_HPP