An open API service indexing awesome lists of open source software.

https://github.com/dmthuc/object-pool

C++ Fast, Static and Generic Object Pool library with smart pointer
https://github.com/dmthuc/object-pool

cpp14 objectpool smart-pointer static-object-pool-cpp

Last synced: 9 months ago
JSON representation

C++ Fast, Static and Generic Object Pool library with smart pointer

Awesome Lists containing this project

README

          

Object-Pool with smart-pointer [![Build Status](https://travis-ci.org/dmthuc/Object-Pool.svg?branch=master)](https://travis-ci.org/dmthuc/Object-Pool)
=====

C++ Fast, Static and Generic Object Pool library with smart pointer
This is static object pool library. It mean that object pool has fixed number of object it manages. Client can't add more object after initialization.
Because it is static so there's no malloc and all operators except constructors are noexcept and fast.
- Contact: minhthucdao1@gmail.com
- Usage: just include pool.hpp into your source code

```cpp
#include "pool.hpp"

Pool pool;
auto obj1 = pool.acquire();
if (nullptr != obj.get())
dosomething(*obj);
else
throw("no object in pool available");

//with compound type, client can pass parameters for the constructor of containing object
Pool pool{args1, args2}

//can also construct it with a range, this is the most useful case.
vector vec{Foo{1}, Foo{2});
//each element of the range will be moved to pool, client have to keep track of number himself
Pool pool(vec.begin(), vec.end());

//also can construct with initializer list, which will be copied from.
Pool pool{Foo{1}, Foo{2}};

//iterate to const element
for(const auto& e: pool)
cout<