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