acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
heap_item_array.h
1#pragma once
2
3
4class CLASS_DECL_ACME heap_item_array:
5 public array < heap_item,heap_item >
6{
7public:
8
9#ifdef UNIVERSAL_WINDOWS
10 class ::time m_timeLastCleanup;
11#else
12 class ::time m_timeLastCleanup;
13#endif
14
15 inline void add_item(void * p,memsize iSize)
16 {
17#ifdef UNIVERSAL_WINDOWS
18 add(heap_item(point,iSize,GetTickCount64()));
19 if(GetTickCount64() > m_timeLastCleanup + 10000)
20#else
21 add(heap_item(point,iSize,::get_tick()));
22 if(::get_tick() > m_timeLastCleanup + 10000)
23#endif
24 {
25 cleanup();
26 }
27 }
28
29 inline void cleanup()
30 {
31#ifdef UNIVERSAL_WINDOWS
32 DWORD64 dwLimit = GetTickCount64() - 1000;
33#else
34 DWORD64 dwLimit= class ::time::now() - 1000;
35#endif
36 for(::i32 i = 0; i < this->get_count();)
37 {
38 if(dwLimit > m_pData[i].m_dwTickCount)
39 {
40 erase_at(i);
41 }
42 else
43 {
44 i++;
45 }
46 }
47#ifdef UNIVERSAL_WINDOWS
48 m_timeLastCleanup = GetTickCount64();
49#else
50 m_timeLastCleanup= class ::time::now();
51#endif
52 }
53
54 inline bool find(void * p,bool bRemove)
55 {
56 __UNREFERENCED_PARAMETER(bRemove);
57
58 for(::i32 mi = 0; mi < this->get_count(); mi++)
59 {
60 if(m_pData[mi].contains(point))
61 {
62 erase_at(mi);
63 return true;
64 }
65 }
66 return false;
67 }
68
69
70};
71
72
Definition heap_item_array.h:6
Definition heap_item.h:5