acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
management.h
1//
2// _heap.h
3// acme
4//
5// Created by Camilo Sasuke Thomas Borregaard Soerensen on 28/02/20.
6// Refactoring 2023-11-23 05:39 <3ThomasBorregaardSoerensen!!
7//
8#pragma once
9
10
11//#include "counter.h"
12
13
14class plex_heap_alloc;
15
16
17namespace c { class malloc; }
18
19
20namespace acme
21{
22
23
24 class acme;
25
26
27} // namespace acme
28
29
30namespace heap
31{
32
33
34 class allocator;
35 class memory;
36
37
38
39 class CLASS_DECL_ACME management
40 {
41 protected:
42
43
44 friend class ::c::malloc;
45
46
47 management();
48 ~management();
49
50
51 public:
52
53
54 class memory * m_memorya[::heap::e_memory_count];
55 bool m_bDestroyIfEmpty;
56 ::acme::acme * m_pacmeDestroyOnDestroy;
57
58
59 //inline static class allocator * s_allocatora[::heap::e_allocator_count];
60
61
62 class allocator * m_pallocator;
63
64
65 //inline static class heap * s_heapa[::heap::e_heap_count];
66
67
68 ::acme::acme * m_pacme;
69
70
71 //::heap::counter < ::particle * > * m_pcounterParticle;
72
73
74
75
76 void initialize_memory_management(::acme::acme * pacme);
77 void finalize_memory_management();
78
79
80 virtual void start_management();
81
82 void enable_particle_counter();
83 void disable_particle_counter();
84
85 void dump_particle_counters();
86
87 inline class memory * memory(enum_memory ememory) { return m_memorya[ememory]; }
88
89
90
91 // Created by Camilo Sasuke Thomas Borregaard Soerensen on 28/02/20.
92 inline class memory * main_memory() { return memory(::heap::e_memory_main); }
93 inline class memory * secondary_memory() { return memory(::heap::e_memory_secondary); }
94 inline class memory * array_memory() { return memory(::heap::e_memory_array); }
95 inline class memory * property_memory() { return memory(::heap::e_memory_property); }
96 inline class memory * string_memory() { return memory(::heap::e_memory_string); }
97
98
99
100 class memory * _new_memory(enum_memory ememory);
101 class memory * new_memory(enum_memory ememory);
102
103
104
105 //inline static class allocator * allocator(enum_allocator eallocator)
106 //{
107
108 // return s_allocatora[eallocator];
109
110 //}
111 inline class allocator * allocator()
112 {
113
114 return m_pallocator;
115
116 }
117
118
119 //inline static class allocator * system_allocator() { return allocator(::heap::e_allocator_system); }
120 //inline static class allocator * default_allocator() { return allocator(::heap::e_allocator_default); }
121 //inline static class allocator * memory_allocator() { return allocator(::heap::e_allocator_memory); }
122 //inline static class allocator * malloc_allocator() { return allocator(::heap::e_allocator_malloc); }
123 //inline static class allocator * a2_allocator() { return allocator(::heap::e_allocator_a2); }
124
125
126 class allocator * _new_allocator(enum_allocator eallocator);
127 class allocator * new_allocator(enum_allocator eallocator);
128
129
130 void memdleak_dump();
131
132 //inline static class heap * heap(enum_heap eheap) { return s_heapa[eheap]; }
133
134
135
137 //inline static class heap * default_heap() { return heap(::heap::e_heap_default); }
142
143
144
145 class heap * _new_heap(enum_heap eheap, ::heap::enum_memory ememory);
146 class heap * new_heap(enum_heap eheap, ::heap::enum_memory ememory);
147
148
149 void on_plex_heap_alloc(plex_heap_alloc * palloc);
150 void on_system_heap_alloc(memsize memsize);
151
152
153
154// namespace secondary_memory_allocate_heap
155// {
156//
157//
158//#include "__aligned_memory_allocate.h"
159//#include "__unaligned_memory_allocate.h"
160//#include "__memory_allocate.h"
161//
162//
163// }
164//
165//
166// namespace array_memory_allocate_heap
167// {
168//
169//
170//#include "__aligned_memory_allocate.h"
171//#include "__unaligned_memory_allocate.h"
172//#include "__memory_allocate.h"
173//
174//
175// }
176//
177//
178//
179// namespace property_memory_allocate_heap
180// {
181//
182//
183//#include "__aligned_memory_allocate.h"
184//#include "__unaligned_memory_allocate.h"
185//#include "__memory_allocate.h"
186//
187//
188// }
189//
190//
191// namespace string_memory_allocate_heap
192// {
193//
194//
195//#include "__aligned_memory_allocate.h"
196//#include "__unaligned_memory_allocate.h"
197//#include "__memory_allocate.h"
198//
199//
200// }
201
202
203
204 virtual void on_plex_new_block(::u32 nAllocSize);
205
206 };
207
208
209
210// class CLASS_DECL_ACME heap_base
211// {
212// public:
213//
214//
215// void * m_p;
216// memsize m_uiSize;
217//
218//
219// heap_base()
220// {
221//
222// m_p = nullptr;
223// m_uiSize = 0;
224//
225// }
226//
227// heap_base(memsize uiSize)
228// {
229//
230// m_p = nullptr;
231// m_uiSize = 0;
232//
233// i32_size(uiSize);
234//
235// }
236//
237// virtual ~heap_base()
238// {
239//
240// _free();
241//
242// }
243//
244// memsize size()
245// {
246//
247// return m_uiSize;
248//
249// }
250//
251//
252// void zero();
253//
254//
255// virtual memsize size(memsize uiSize)
256// {
257//
258// if(m_p == nullptr)
259// {
260//
261// m_p = ::system()->m_pheapmanagement->memory(::heap::e_memory_main)->allocate(uiSize);
262//
263// }
264// else
265// {
266//
267// m_p = memory_reallocate(m_p,uiSize);
268//
269// }
270//
271// if(m_p != nullptr)
272// {
273//
274// m_uiSize = uiSize;
275//
276// }
277//
278// return m_uiSize;
279//
280// }
281//
282//
283// void _free()
284// {
285//
286// if(m_p != nullptr)
287// {
288//
289// ::system()->m_pheapmanagement->memory(::heap::e_memory_main)->free(m_p);
290//
291// m_p = nullptr;
292//
293// }
294//
295// }
296//
297//
298// };
299//
300
301// template < typename T >
302// class heap:
303// public heap_base
304// {
305// public:
306//
307//
308// heap() { }
309//
310// heap(memsize iCount): heap_base(iCount * sizeof(T)) { }
311//
312// operator T * () { return (T *)m_p; }
313// operator const T * () const { return (T *)m_p; }
314//
315// memsize count() { return size() / sizeof(T); }
316//
317// void stralloc(::collection::count cChar) { i32_size((cChar + 1) * sizeof(T)); }
318//
319// string & to_string(string & str) const;
320//
321// };
322//
323
324} // namespace heap
325
326
327
328//typedef ::heap::heap < ::i8 > hstring_base;
329//
330//class CLASS_DECL_ACME hstring:
331// public hstring_base
332//{
333//public:
334//
335// hstring() {}
336// hstring(memsize uiSize): hstring_base(uiSize) {}
337//
338//};
339
340
341//typedef ::heap::heap < unichar > hwstring_base;
342//
343//class CLASS_DECL_ACME wstring:
344// public hwstring_base
345//{
346//public:
347//
348// wstring() {}
349// wstring(memsize uiSize): hwstring_base(uiSize) {}
350//
351//};
352
Definition acme.h:22
Definition c_malloc.h:13
Definition allocator.h:37
Definition heap.h:10
Definition memory.h:23
Definition plex_heap_alloc.h:9
include "aura/graphics/image/context.h"
Definition aaaa__defer.h:32