* Fixed adaptive pool bugs

* Improved adaptive pool testing enabling invariant checking in debug mode.
* New compile-time and runtime calculated parameters for adaptive_pool.
* New test comparing set with default allocator or adaptive pool
This commit is contained in:
Ion Gaztañaga committed 2018-04-29 12:42:04 +02:00
1 parent 42c6be5887
commit 04b0791593
9 files changed
+1398 -512

No files matched your search

@@ -39,17 +39,6 @@ namespace boost {
namespace container {
namespace dtl {
template<bool AlignOnly>
struct select_private_adaptive_node_pool_impl
{
typedef boost::container::dtl::
private_adaptive_node_pool_impl
< fake_segment_manager
, unsigned(AlignOnly)*::boost::container::adaptive_pool_flag::align_only
| ::boost::container::adaptive_pool_flag::size_ordered | ::boost::container::adaptive_pool_flag::address_ordered
> type;
};
//!Pooled memory allocator using an smart adaptive pool. Includes
//!a reference count but the class does not delete itself, this is
//!responsibility of user classes. Node size (NodeSize) and the number of
@@ -60,24 +49,38 @@ template< std::size_t NodeSize
, std::size_t OverheadPercent
>
class private_adaptive_node_pool
: public select_private_adaptive_node_pool_impl<(OverheadPercent == 0)>::type
: public private_adaptive_node_pool_impl_ct
< fake_segment_manager
, MaxFreeBlocks
, NodeSize
, NodesPerBlock
, OverheadPercent
, unsigned(OverheadPercent == 0)*::boost::container::adaptive_pool_flag::align_only
| ::boost::container::adaptive_pool_flag::size_ordered
| ::boost::container::adaptive_pool_flag::address_ordered
>
{
typedef typename select_private_adaptive_node_pool_impl<OverheadPercent == 0>::type base_t;
typedef private_adaptive_node_pool_impl_ct
< fake_segment_manager
, MaxFreeBlocks
, NodeSize
, NodesPerBlock
, OverheadPercent
, unsigned(OverheadPercent == 0)*::boost::container::adaptive_pool_flag::align_only
| ::boost::container::adaptive_pool_flag::size_ordered
| ::boost::container::adaptive_pool_flag::address_ordered
> base_t;
//Non-copyable
private_adaptive_node_pool(const private_adaptive_node_pool &);
private_adaptive_node_pool &operator=(const private_adaptive_node_pool &);
public:
typedef typename base_t::multiallocation_chain multiallocation_chain;
static const std::size_t nodes_per_block = NodesPerBlock;
//!Constructor. Never throws
private_adaptive_node_pool()
: base_t(0
, NodeSize
, NodesPerBlock
, MaxFreeBlocks
, (unsigned char)OverheadPercent)
: base_t(0)
{}
};