|
Sese Framework
3.0.0
A cross-platform framework
|
Concurrent object pool. More...
#include <ObjectPool.h>
Public Types | |
| using | Ptr = std::shared_ptr<ObjectPool<T>> |
| using | ObjectPtr = std::shared_ptr<T> |
Public Member Functions | |
| ~ObjectPool () override | |
| ObjectPtr | borrow () |
Public Member Functions inherited from sese::Noncopyable | |
| Noncopyable ()=default | |
| virtual | ~Noncopyable ()=default |
| Noncopyable (const Noncopyable &)=delete | |
| Noncopyable & | operator= (const Noncopyable &)=delete |
Static Public Member Functions | |
| static Ptr | create () |
Private Member Functions | |
| ObjectPool ()=default | |
Static Private Member Functions | |
| static void | recycleCallback (const std::weak_ptr< ObjectPool< T > > &wk_pool, T *t) |
Private Attributes | |
| LinkedQueue< T * > | queue |
Concurrent object pool.
| T | The type of objects in the pool |
| using sese::concurrent::ObjectPool< T >::ObjectPtr = std::shared_ptr<T> |
| using sese::concurrent::ObjectPool< T >::Ptr = std::shared_ptr<ObjectPool<T>> |
|
inlineoverride |
|
privatedefault |
|
inline |
Retrieves a reusable object from the object pool
References sese::concurrent::LinkedQueue< T >::pop(), sese::concurrent::ObjectPool< T >::queue, and sese::concurrent::ObjectPool< T >::recycleCallback().
|
inlinestatic |
The object pool can only be created on the heap
|
inlinestaticprivate |
Destructor for the borrowed object
| wk_pool | A weak pointer to the object pool that the object belongs to, used for triggering the recycling logic |
| t | The object to be recycled |
Referenced by sese::concurrent::ObjectPool< T >::borrow().
|
private |