https://github.com/kautenja/object-pool
A simple template implementation of an object pool in C++.
https://github.com/kautenja/object-pool
cpp11 header-only object-pool tested
Last synced: 6 months ago
JSON representation
A simple template implementation of an object pool in C++.
- Host: GitHub
- URL: https://github.com/kautenja/object-pool
- Owner: Kautenja
- License: mit
- Created: 2019-09-11T20:07:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-11T20:26:04.000Z (about 6 years ago)
- Last Synced: 2025-02-14T10:18:24.787Z (8 months ago)
- Topics: cpp11, header-only, object-pool, tested
- Language: C++
- Homepage:
- Size: 693 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Object Pool
[![build-status][]][build-server]
[build-status]: https://travis-ci.com/Kautenja/object-pool.svg
[build-server]: https://travis-ci.com/Kautenja/object-pool## Usage
Simply add [include/object_pool.hpp](include/object_pool.hpp) to your C++
project either by copying directly or using git submodules.## Classes
There are two working implementations of the object pool, (1) the object
managed pool that stores objects on the stack using a vector, and (2) the
object pointer pool that stores objects dynamically in memory.
[benchmark/benchmark.cpp](benchmark/benchmark.cpp) contains code to benchmark
the objects (using doubles as the template object type).| Class | Object location | `get` & `put` avg. time |
|:--------------------|:------------------|:------------------------|
| `ObjectManagedPool` | Stack | 194_ns_ (267_ns_ std.)
| `ObjectPointerPool` | Heap | 47_ns_ (2_ns_ std.)The `ObjectPool` class defaults to the faster (and simpler) `ObjectPointerPool`
class.## Testing
To compile and run the [test suite](test):
```shell
scons test
```## Benchmarking
To run benchmarks:
```shell
scons benchmark/benchmark.cpp
```