15#include <AUI/Common/AQueue.h>
16#include <AUI/Common/SharedPtrTypes.h>
21 using Factory = std::function<_unique<T>()>;
24 std::shared_ptr<bool> mPoolAlive = std::make_shared<bool>(
true);
27 template <
typename Ptr = _<T>>
28 Ptr getImpl()
noexcept {
33 t = std::move(mQueue.front());
36 if constexpr (std::is_same_v<Ptr, _<T>>) {
39 return std::unique_ptr<T, APoolDeleter>(t.release(),
APoolDeleter(
this));
44 explicit APool(
Factory factory) noexcept : mFactory(std::move(factory)) {}
48 std::shared_ptr<bool> poolAlive;
52 void operator()(T* t) {
54 pool->mQueue.push(_unique<T>(t));
65 return getImpl<_<T>>();
68 using UniquePtr = std::unique_ptr<T, APoolDeleter>;
70 auto getUnique() noexcept {
71 return getImpl<UniquePtr>();
A std::queue with AUI extensions.
Definition: AQueue.h:24
Forbids copy of your class.
Definition: values.h:40
static _< T > manage(T *raw)
Definition: SharedPtrTypes.h:371