Deluge Firmware
1.3.0
Build date: 2026.08.29
Toggle main menu visibility
Loading...
Searching...
No Matches
cache_manager.h
1
#pragma once
2
3
#include "definitions_cxx.hpp"
4
#include "memory/stealable.h"
5
#include "util/container/list/bidirectional_linked_list.h"
6
#include "util/misc.h"
7
#include <array>
8
#include <cstddef>
9
10
class
MemoryRegion
;
11
12
class
CacheManager {
13
public
:
14
CacheManager() =
default
;
15
16
BidirectionalLinkedList
& queue(StealableQueue destination) {
17
return
reclamation_queue_.at(util::to_underlying(destination));
18
}
19
20
uint32_t& longest_runs(
size_t
idx) {
return
longest_runs_.at(idx); }
21
23
void
QueueForReclamation
(StealableQueue queue,
Stealable
* stealable) {
24
size_t
q = util::to_underlying(queue);
25
32
reclamation_queue_[q].addToEnd(stealable);
33
longest_runs_[q] = 0xFFFFFFFF;
// TODO: actually investigate neighbouring memory "run".
34
}
35
36
uint32_t ReclaimMemory(
MemoryRegion
& region, int32_t totalSizeNeeded,
void
* thingNotToStealFrom,
37
int32_t* __restrict__ foundSpaceSize);
38
39
private
:
40
std::array<BidirectionalLinkedList, kNumStealableQueue> reclamation_queue_;
41
42
// Keeps track, semi-accurately, of biggest runs of memory that could be stolen. In a perfect world, we'd have a
43
// second index on stealableClusterQueues[q], for run length. Although even that wouldn't automatically reflect
44
// changes to run lengths as neighbouring memory is allocated.
45
std::array<uint32_t, kNumStealableQueue> longest_runs_;
46
};
BidirectionalLinkedList
Definition
bidirectional_linked_list.h:38
CacheManager::QueueForReclamation
void QueueForReclamation(StealableQueue queue, Stealable *stealable)
add a stealable to end of given queue
Definition
cache_manager.h:23
MemoryRegion
Definition
memory_region.h:44
Stealable
Definition
stealable.h:25