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
- Host: GitHub
- URL: https://github.com/dmthuc/object-pool
- Owner: dmthuc
- License: gpl-3.0
- Created: 2018-03-16T04:29:29.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-01T09:42:19.000Z (almost 7 years ago)
- Last Synced: 2025-03-27T00:54:12.944Z (9 months ago)
- Topics: cpp14, objectpool, smart-pointer, static-object-pool-cpp
- Language: C++
- Size: 25.4 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Object-Pool with smart-pointer [](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<