ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
MTGenericPool.hpp
1#pragma once
2
3#include "MTObjectPool.hpp"
4
5namespace CP_SDK::Pool {
6
9 template<class t_Type>
11 {
12 CP_SDK_NO_DEF_CTORS(MTGenericPool);
13
14 private:
15 static typename MTObjectPool<t_Type>::Ptr s_Pool;
16
17 public:
19 static t_Type Get()
20 {
21 return s_Pool->Get();
22 }
25 static void Release(t_Type& p_Element)
26 {
27 s_Pool->Release(p_Element);
28 }
29
30 };
31
32 template <typename t_Type>
33 typename MTObjectPool<t_Type>::Ptr MTGenericPool<t_Type>::s_Pool = MTObjectPool<t_Type>::Make(
34 []() {
35 if constexpr (std::is_pointer_v<t_Type>)
36 {
37 using t_ExtractedType = typename std::remove_pointer<t_Type>::type;
38 return new t_ExtractedType();
39 }
40 else
41 return t_Type();
42 },
43 nullptr,
44 nullptr,
45 [](t_Type& x) {
46 if constexpr (std::is_pointer_v<t_Type>)
47 delete x;
48 }
49 );
50
51}
Provides a static implementation of Pool.ObjectPool_1.
static void Release(t_Type &p_Element)
Release an element.
static t_Type Get()
Simple get.
void Release(t_Type &p_Element) override
Release an element.
t_Type Get() override
Simple get.
static Ptr Make(_v::CFuncRef< t_Type > createFunc, _v::CActionRef< t_Type & > actionOnGet=nullptr, _v::CActionRef< t_Type & > actionOnRelease=nullptr, _v::CActionRef< t_Type & > actionOnDestroy=nullptr, bool collectionCheck=true, int defaultCapacity=10, int maxSize=100)
Constructor.
Memory management & pools utilities.