Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Object Pool

$
0
0
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.

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>