Alien-boost-mini
view release on metacpan or search on metacpan
include/boost/container/adaptive_pool.hpp view on Meta::CPAN
//!NodesPerBlock is the number of nodes allocated at once when the allocator
//!needs runs out of nodes. MaxFreeBlocks is the maximum number of totally free blocks
//!that the adaptive node pool will hold. The rest of the totally free blocks will be
//!deallocated to the memory manager.
//!
//!OverheadPercent is the (approximated) maximum size overhead (1-20%) of the allocator:
//!(memory usable for nodes / total memory allocated from the memory allocator)
template < class T
, std::size_t NodesPerBlock BOOST_CONTAINER_DOCONLY(= ADP_nodes_per_block)
, std::size_t MaxFreeBlocks BOOST_CONTAINER_DOCONLY(= ADP_max_free_blocks)
, std::size_t OverheadPercent BOOST_CONTAINER_DOCONLY(= ADP_overhead_percent)
BOOST_CONTAINER_DOCIGN(BOOST_MOVE_I unsigned Version)
>
class adaptive_pool
{
//!If Version is 1, the allocator is a STL conforming allocator. If Version is 2,
//!the allocator offers advanced expand in place and burst allocation capabilities.
public:
typedef unsigned int allocation_type;
typedef adaptive_pool
<T, NodesPerBlock, MaxFreeBlocks, OverheadPercent
BOOST_CONTAINER_DOCIGN(BOOST_MOVE_I Version)
> self_t;
static const std::size_t nodes_per_block = NodesPerBlock;
static const std::size_t max_free_blocks = MaxFreeBlocks;
static const std::size_t overhead_percent = OverheadPercent;
static const std::size_t real_nodes_per_block = NodesPerBlock;
BOOST_CONTAINER_DOCIGN(BOOST_STATIC_ASSERT((Version <=2)));
public:
//-------
typedef T value_type;
typedef T * pointer;
typedef const T * const_pointer;
typedef typename ::boost::container::
include/boost/container/adaptive_pool.hpp view on Meta::CPAN
template < class T
, std::size_t NodesPerBlock = ADP_nodes_per_block
, std::size_t MaxFreeBlocks = ADP_max_free_blocks
, std::size_t OverheadPercent = ADP_overhead_percent
, unsigned Version = 2
>
class private_adaptive_pool
{
//!If Version is 1, the allocator is a STL conforming allocator. If Version is 2,
//!the allocator offers advanced expand in place and burst allocation capabilities.
public:
typedef unsigned int allocation_type;
typedef private_adaptive_pool
<T, NodesPerBlock, MaxFreeBlocks, OverheadPercent
BOOST_CONTAINER_DOCIGN(BOOST_MOVE_I Version)
> self_t;
static const std::size_t nodes_per_block = NodesPerBlock;
static const std::size_t max_free_blocks = MaxFreeBlocks;
static const std::size_t overhead_percent = OverheadPercent;
static const std::size_t real_nodes_per_block = NodesPerBlock;
BOOST_CONTAINER_DOCIGN(BOOST_STATIC_ASSERT((Version <=2)));
typedef dtl::private_adaptive_node_pool
<sizeof(T), NodesPerBlock, MaxFreeBlocks, OverheadPercent> pool_t;
pool_t m_pool;
public:
//-------
include/boost/container/container_fwd.hpp view on Meta::CPAN
string;
typedef basic_string
<wchar_t
,std::char_traits<wchar_t>
,new_allocator<wchar_t> >
wstring;
static const std::size_t ADP_nodes_per_block = 256u;
static const std::size_t ADP_max_free_blocks = 2u;
static const std::size_t ADP_overhead_percent = 1u;
static const std::size_t ADP_only_alignment = 0u;
template < class T
, std::size_t NodesPerBlock = ADP_nodes_per_block
, std::size_t MaxFreeBlocks = ADP_max_free_blocks
, std::size_t OverheadPercent = ADP_overhead_percent
, unsigned Version = 2
>
class adaptive_pool;
template < class T
, unsigned Version = 2
, unsigned int AllocationDisableMask = 0>
class allocator;
static const std::size_t NodeAlloc_nodes_per_block = 256u;
include/boost/container/detail/adaptive_node_pool_impl.hpp view on Meta::CPAN
//
// candidate_power_of_2_ct
//
/////////////////////////////////////////////
template< std::size_t alignment
, std::size_t real_node_size
, std::size_t payload_per_allocation
, std::size_t min_elements_per_block
, std::size_t hdr_size
, std::size_t hdr_offset_size
, std::size_t overhead_percent>
struct candidate_power_of_2_ct_helper
{
static const std::size_t hdr_subblock_elements_alone = (alignment - hdr_size - payload_per_allocation)/real_node_size;
static const std::size_t hdr_subblock_elements_first = (alignment - hdr_size - payload_per_allocation)/real_node_size;
static const std::size_t elements_per_b_subblock_mid = (alignment - hdr_offset_size)/real_node_size;
static const std::size_t elements_per_b_subblock_end = (alignment - hdr_offset_size - payload_per_allocation)/real_node_size;
static const std::size_t num_b_subblock =
hdr_subblock_elements_alone >= min_elements_per_block
? 0
: ( ((hdr_subblock_elements_first + elements_per_b_subblock_end) >= min_elements_per_block)
include/boost/container/detail/adaptive_node_pool_impl.hpp view on Meta::CPAN
static const std::size_t total_nodes = (num_b_subblock == 0)
? hdr_subblock_elements_alone
: ( (num_b_subblock == 1)
? (hdr_subblock_elements_first + elements_per_b_subblock_end)
: (hdr_subblock_elements_first + num_b_subblock_mid*elements_per_b_subblock_mid + elements_per_b_subblock_end)
)
;
static const std::size_t total_data = total_nodes*real_node_size;
static const std::size_t total_size = alignment*(num_b_subblock+1);
static const bool overhead_satisfied = (total_size - total_data)*100/total_size < overhead_percent;
};
template< std::size_t initial_alignment
, std::size_t real_node_size
, std::size_t payload_per_allocation
, std::size_t min_elements_per_block
, std::size_t hdr_size
, std::size_t hdr_offset_size
, std::size_t overhead_percent
, bool Loop = true>
struct candidate_power_of_2_ct
{
typedef candidate_power_of_2_ct_helper
< initial_alignment
, real_node_size
, payload_per_allocation
, min_elements_per_block
, hdr_size
, hdr_offset_size
, overhead_percent> helper_t;
static const std::size_t candidate_power_of_2 = initial_alignment << std::size_t(!helper_t::overhead_satisfied);
typedef typename candidate_power_of_2_ct
< candidate_power_of_2
, real_node_size
, payload_per_allocation
, min_elements_per_block
, hdr_size
, hdr_offset_size
, overhead_percent
, !helper_t::overhead_satisfied
>::type type;
static const std::size_t alignment = type::alignment;
static const std::size_t num_subblocks = type::num_subblocks;
static const std::size_t real_num_node = type::real_num_node;
};
template< std::size_t initial_alignment
, std::size_t real_node_size
, std::size_t payload_per_allocation
, std::size_t min_elements_per_block
, std::size_t hdr_size
, std::size_t hdr_offset_size
, std::size_t overhead_percent
>
struct candidate_power_of_2_ct
< initial_alignment
, real_node_size
, payload_per_allocation
, min_elements_per_block
, hdr_size
, hdr_offset_size
, overhead_percent
, false>
{
typedef candidate_power_of_2_ct
< initial_alignment
, real_node_size
, payload_per_allocation
, min_elements_per_block
, hdr_size
, hdr_offset_size
, overhead_percent
, false> type;
typedef candidate_power_of_2_ct_helper
< initial_alignment
, real_node_size
, payload_per_allocation
, min_elements_per_block
, hdr_size
, hdr_offset_size
, overhead_percent> helper_t;
static const std::size_t alignment = initial_alignment;
static const std::size_t num_subblocks = helper_t::num_b_subblock+1;
static const std::size_t real_num_node = helper_t::total_nodes;
};
/////////////////////////////////////////////
//
// candidate_power_of_2_rt
//
/////////////////////////////////////////////
void candidate_power_of_2_rt ( std::size_t initial_alignment
, std::size_t real_node_size
, std::size_t payload_per_allocation
, std::size_t min_elements_per_block
, std::size_t hdr_size
, std::size_t hdr_offset_size
, std::size_t overhead_percent
, std::size_t &alignment
, std::size_t &num_subblocks
, std::size_t &real_num_node)
{
bool overhead_satisfied = false;
std::size_t num_b_subblock = 0;
std::size_t total_nodes = 0;
while(!overhead_satisfied)
{
include/boost/container/detail/adaptive_node_pool_impl.hpp view on Meta::CPAN
total_nodes = (num_b_subblock == 0)
? hdr_subblock_elements_alone
: ( (num_b_subblock == 1)
? (hdr_subblock_elements_first + elements_per_b_subblock_end)
: (hdr_subblock_elements_first + num_b_subblock_mid*elements_per_b_subblock_mid + elements_per_b_subblock_end)
)
;
std::size_t total_data = total_nodes*real_node_size;
std::size_t total_size = initial_alignment*(num_b_subblock+1);
overhead_satisfied = (total_size - total_data)*100/total_size < overhead_percent;
initial_alignment = initial_alignment << std::size_t(!overhead_satisfied);
}
alignment = initial_alignment;
num_subblocks = num_b_subblock+1;
real_num_node = total_nodes;
}
/////////////////////////////////////////////
//
// private_adaptive_node_pool_impl_common
include/boost/container/detail/adaptive_node_pool_impl.hpp view on Meta::CPAN
//!Segment manager typedef
typedef SegmentManagerBase segment_manager_base_type;
//!Constructor from a segment manager. Never throws
private_adaptive_node_pool_impl_rt
( segment_manager_base_type *segment_mngr_base
, size_type node_size
, size_type nodes_per_block
, size_type max_free_blocks
, unsigned char overhead_percent
)
: data_t(max_free_blocks, lcm(node_size, size_type(alignment_of<void_pointer>::value)))
, impl_t(segment_mngr_base)
{
if(AlignOnly){
this->m_real_block_alignment = upper_power_of_2(HdrSize + this->m_real_node_size*nodes_per_block);
this->m_real_num_node = (this->m_real_block_alignment - PayloadPerAllocation - HdrSize)/this->m_real_node_size;
}
else{
candidate_power_of_2_rt ( upper_power_of_2(HdrSize + PayloadPerAllocation + this->m_real_node_size)
, this->m_real_node_size
, PayloadPerAllocation
, nodes_per_block
, HdrSize
, HdrOffsetSize
, overhead_percent
, this->m_real_block_alignment
, this->m_num_subblocks
, this->m_real_num_node);
}
}
//!Destructor. Deallocates all allocated blocks. Never throws
~private_adaptive_node_pool_impl_rt()
{ this->priv_clear(this->m_num_subblocks, this->m_real_block_alignment, this->m_real_num_node); }
( run in 0.402 second using v1.01-cache-2.11-cpan-10c994e2082 )