Hi!
I wrote object pool. This is single-header library for fast object allocation. All objects inside of the pool placed in a contiguous memory block to be cache-friendly. Detailed description is in repository.
https://github.com/mrDIMAS/SmartPool
Here is some examples:
class Foo {
private:
int fooBar;
public:
Foo() {}
Foo(int foobar) : fooBar(foobar) {}
};
...
Pool<Foo> pool(1024); // make pool with default capacity of 1024 objects
Handle<Foo> bar = pool.Spawn(); // spawn object with default constructor
Handle<Foo> baz = pool.Spawn(42); // spawn object with any args
// do something
// return object to pool
pool.Return(bar);
pool.Return(baz);
Results of tests are in attached files.
Please, criticize it and give me some feedback.
↧