Skip to content

A thread-safe header-only object pool implemented using unique pointers to store trivially copyable types

License

Notifications You must be signed in to change notification settings

avikor/StackfullObjectPool

Repository files navigation

StackfullObjectPool

This repository contains a thread-safe header-only stackfull object pool under 'StackfullObjectPool/StackfullObjectPool.hpp'.
For some toy examples look at 'StackfullObjectPool/StackfullObjectPoolTests.cpp'.
NOTE #1: The pool is meant to store only Trivially Copyable types, and it is enforced by a concept. Hence it's appropriate to use it to store Plain Old Data types (PODs) and the likes.
NOTE #2: A trivially copyable type must have a Trivial Destructor, hence the destructor of the pool's objects is never called upon releasing them. Rather the bytes used to store the object are overwritten and reused.
NOTE #3: The pool-objects type need not define a default constructor.
NOTE #4: The pool's lifetime must exceed that of its objects, otherwise it'll lead to undefined behavior.

Some implementation details

The pool items' allocation and deallocation is managed using std::unique_ptr.
Under the hood, the pool is implemented using std::array of std::byte.
The next open slot in the pool is managed using a stack.

About

A thread-safe header-only object pool implemented using unique pointers to store trivially copyable types

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published