![]() |
Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
|
#include <ResourcePool.h>
Data Structures | |
class | Deleter |
Public Types | |
using | Factory = std::function<T*()> |
using | Free = std::function<void(T*)> |
using | UniquePtr = std::unique_ptr<T, Deleter> |
Public Member Functions | |
ResourcePool (Factory factory, Free free) | |
UniquePtr | get () |
~ResourcePool () noexcept | |
ResourcePool (Factory factory, Free free) | |
UniquePtr | get () |
~ResourcePool () noexcept | |
ResourcePool (Factory factory, Free free) | |
UniquePtr | get () |
~ResourcePool () noexcept | |
An unbounded pool of resources. A ResourcePool<T>
requires a factory function that takes allocates T*
and a free function that frees a T*
. Calling ResourcePool::get()
will give you a new ResourcePool::UniquePtr
to a T
, and when it goes out of scope the resource will be returned to the pool. The ResourcePool<T>
must survive longer than any resources it hands out. Remember that ResourcePool<T>
hands out mutable T
s, so make sure to clean up the resource before or after every use.
typedef std::function< T *()> Factory = std::function<T*()> |
typedef std::function< void(T *)> Free = std::function<void(T*)> |
|
inline |
Creates a ResourcePool
.
factory | The function to use to create new resources. |
free | The function to use to free resources created by factory . |
|
inlinenoexcept |
|
inline |
Creates a ResourcePool
.
factory | The function to use to create new resources. |
free | The function to use to free resources created by factory . |
|
inlinenoexcept |
|
inline |
Creates a ResourcePool
.
factory | The function to use to create new resources. |
free | The function to use to free resources created by factory . |
|
inlinenoexcept |
|
inline |
factory()
returns null.
|
inline |
factory()
returns null.
|
inline |
factory()
returns null.