Clarification on the template "pool of objects"?

I got the impression that object poolthis is a design pattern used to manage a group of pre-selected objects to which the client can request and return one of these objects. However, it seems that the class is boost.pool object_poolmore associated with lower-level memory management than object management. Why did they go with that name, unlike something like memory_pool? Am I under the wrong impression that the object pool is really a memory pooling scheme? Or are they essentially the same? Also, why wasn’t the standard implementation of a higher level object pool template?

+4
source share
1 answer

After a more detailed examination of the documentation boost.pool, I think I understand my confusion. I am used to thinking about an object pool implemented as a class that allocates and manages a set of direct objects. Consider

template<class T>
class object_pool {
private:
  std::list<T*> m_reserved; // holds onto any objects that have been allocated
public
  T *acquire() { /* grabs from reserved list */ }
};

However, it seems that it boost.poolimplements a different concept of the pool of objects, which is used for a completely different purpose than the one proposed above. boost.poolallocates and manages the base memory of the desired object (s), presumably so that it can increase heap performance using what it describes as Simple Segregated Storage . Actually, this concept of an object pool template does not follow . An explanation of the differences between the two patterns can be found in the answer to my next question .

+5
source

All Articles