I am having problems using distributed memory allocations for std :: list objects in a multi-threaded application.
The part of the code I'm connected to runs each thread function in isolation (i.e. there is no communication or synchronization between threads), and so I would like to set up separate memory pools for each thread, where each pool is not thread-safe (and therefore quick).
I tried using a single-user shared memory streaming pool and found that performance was low, as expected.
This is a very simplified version of the type of thing I'm trying to do. Much has been included in the pseudo-code view, sorry if this is confusing.
class make_quadtree
{
private:
pooled_allocator<int> item_pool;
class local_alloc
{
public :
pointer allocate (size_t n) { return ( item_pool.allocate(n) ); }
};
public :
make_quadtree (): item_pool()
{
std::vector<std::list<int, local_alloc>> lists;
}
};
, , , std:: list.