Template class for buffer pool of the specified buffer type.
UniPtr | Unique pointer type of the buffers in the pool. |
Definition at line 405 of file infer_utils.h.
Public Types | |
using | ItemType = typename UniPtr::element_type |
using | RecylePtr = std::unique_ptr< ItemType, std::function< void(ItemType *)> > |
Public Member Functions | |
BufferPool (const std::string &name) | |
Constructor. More... | |
virtual | ~BufferPool () |
Destructor. More... | |
bool | setBuffer (UniPtr buf) |
Add a buffer to the pool. More... | |
int | size () |
Get the number of free buffers. More... | |
RecylePtr | acquireBuffer () |
Acquire a buffer from the pool. More... | |
using INFER_EXPORT_API::BufferPool< UniPtr >::ItemType = typename UniPtr::element_type |
Definition at line 407 of file infer_utils.h.
using INFER_EXPORT_API::BufferPool< UniPtr >::RecylePtr = std::unique_ptr<ItemType, std::function<void(ItemType*)> > |
Definition at line 408 of file infer_utils.h.
|
inline |
|
inlinevirtual |
Destructor.
Print debug message of number of free buffers.
Definition at line 417 of file infer_utils.h.
References InferDebug, and INFER_EXPORT_API::safeStr().
|
inline |
Acquire a buffer from the pool.
This function pops a buffer from the pool queue. A deleter function is associate with the buffer pointer to return the buffer to the pool when it is no longer needed.
Definition at line 450 of file infer_utils.h.
References InferDebug, and INFER_EXPORT_API::safeStr().
|
inline |
Add a buffer to the pool.
[in] | buf | Unique pointer to a buffer to be added to the pool. |
Definition at line 428 of file infer_utils.h.
References InferDebug, and INFER_EXPORT_API::safeStr().
|
inline |
Get the number of free buffers.
Definition at line 439 of file infer_utils.h.