static bucket_ptr create_buckets(allocator_type &alloc, size_type num) { num = index_type::suggested_upper_bucket_count(num); bucket_ptr buckets = alloc.allocate(num); bucket_ptr buckets_init = buckets; for(size_type i = 0; i < num; ++i){ ::new(to_raw_pointer(buckets_init++), boost_container_new_t())bucket_type(); } return buckets; }
NodePtr create_node_from_it(const It &it) { NodePtr p = this->allocate_one(); Deallocator node_deallocator(p, this->node_alloc()); ::boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), it); node_deallocator.release(); //This does not throw typedef typename Node::hook_type hook_type; ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; return (p); }
NodePtr create_node(Args &&...args) { NodePtr p = this->allocate_one(); Deallocator node_deallocator(p, this->node_alloc()); allocator_traits<NodeAlloc>::construct ( this->node_alloc() , container_detail::addressof(p->m_data), boost::forward<Args>(args)...); node_deallocator.release(); //This does not throw typedef typename Node::hook_type hook_type; ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p)), boost_container_new_t()) hook_type; return (p); }
static bucket_ptr expand_or_create_buckets ( bucket_ptr old_buckets, const size_type old_num , allocator_type &alloc, const size_type new_num) { size_type received_size = new_num; bucket_ptr reuse(old_buckets); bucket_ptr ret = alloc.allocation_command (boost::interprocess::expand_fwd | boost::interprocess::allocate_new, new_num, received_size, reuse); if(ret == old_buckets){ bucket_ptr buckets_init = old_buckets + old_num; for(size_type i = 0; i < (new_num - old_num); ++i){ ::new(to_raw_pointer(buckets_init++), boost_container_new_t())bucket_type(); } } else{ bucket_ptr buckets_init = ret; for(size_type i = 0; i < new_num; ++i){ ::new(to_raw_pointer(buckets_init++), boost_container_new_t())bucket_type(); } } return ret; }
void pool_resource::priv_init_pools() { const std::size_t num_pools = priv_pool_index(m_options.largest_required_pool_block)+1u; //Otherwise, just use the default alloc (zero pools) void *p = 0; //This can throw p = m_upstream.allocate(sizeof(pool_data_t)*num_pools); //This is nothrow m_pool_data = static_cast<pool_data_t *>(p); for(std::size_t i = 0, max = num_pools; i != max; ++i){ ::new(&m_pool_data[i], boost_container_new_t()) pool_data_t(pool_options_minimum_max_blocks_per_chunk); } m_pool_count = num_pools; }