55template <
typename T>
struct tlm_managed_extension :
public tlm_extension<T> {
59 template <
typename... Args>
static type* allocate(Args&&... args) {
60 auto* ret =
new(pool::allocate()) type(std::forward<Args>(args)...);
61 ret->is_pooled =
true;
65 static type* allocate() {
66 auto* ret =
new(pool::allocate()) type();
67 ret->is_pooled =
true;
71 tlm_extension_base* clone()
const {
75 void copy_from(tlm_extension_base
const& other) { this->operator=(
static_cast<const type&
>(other)); }
80 pool::dealllocate(
this);
86 static void* allocate() {
87 if(free_list.size() > 0) {
88 auto ret = free_list.back();
92 return calloc(1,
sizeof(type));
95 static void dealllocate(
void* p) { free_list.push_back(p); }
98 static std::vector<void*> free_list;
102 tlm_managed_extension() =
default;
103 tlm_managed_extension(
const tlm_managed_extension&) =
default;
104 tlm_managed_extension& operator=(
const tlm_managed_extension& other) {
return *
this; }
107 bool is_pooled{
false};