Create a small C/C++ library that implements a generic object pool. This is a small, header only library that implements the functionality of generic object pool.
The functionality of the library is exposed through its public API listed below
- CTORs - default and initialization list
- Add - adds an object to the pool, given its arguments (similar to CTOR)
- Remove - removes the given object from the pool if the object was acquired through the pool. Otherwise the 'Remove' call is ignored.
- Get - gets a unique pointer wrapped object from the pool.
The libary is thread safe and can be used in concurrent
Using this library, we are able to:
- Add healthy objects into the pool.
- Remove objects from the pool (either on demand, of if unhealthy).
- Acquire 1 object from the pool to be used.
- Send the used object back to the pool to be healthchecked before being added back into it.
- See the size of the pool at any given time.
- Be thread safe and fit for concurrent use.
For sample usage, please see the file src/app_main.cpp