Creating an object in boost :: singleton_pool

I am trying to use boost :: singleton_pool to create a large number of Order objects in a high-performance critical multi-threaded expression. Looking at the documentation, this is what I have to do,

struct OrderTag{};
typedef boost::singleton_pool<OrderTag, sizeof(Order)> OrderPool; 

boost :: singleton_pool has a malloc static member function that returns a pointer to void *, but I need to create objects of type Order in OrderPool by calling its constructor. Should I use boost :: pool_allocator along with singleton_pool for this?

Thank.

+3
source share
2 answers

: . boost:: pool_allocator boost:: singleton_pool , std:: allocator, STL ( STL, ), , .. UserAllocator - boost:: pool_allocator, , . , UserAllocator, mmap() .

"", boost:: pool_allocator :: fast_pool_allocator. boost:: singleton_pool .

0

singleton_pool new :

Order* p = new (OrderPool.malloc()) Order(/* add ctor parameters if any*/);

boost::object_pool<Order>

0

All Articles