Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
cache_manager.h
1#pragma once
2
3#include "definitions_cxx.hpp"
4#include "etl/intrusive_list.h"
5#include "memory/stealable.h"
6#include "util/misc.h"
7#include <array>
8#include <cstddef>
9
10class MemoryRegion;
11
12class CacheManager {
13 using list_type = etl::intrusive_list<Stealable, Stealable::link_type>;
14
15public:
16 CacheManager() = default;
17
18 list_type& queue(StealableQueue destination) { return reclamation_queue_.at(util::to_underlying(destination)); }
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].push_back(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
39private:
40 std::array<list_type, 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};
void QueueForReclamation(StealableQueue queue, Stealable &stealable)
add a stealable to end of given queue
Definition cache_manager.h:23
Definition memory_region.h:44
Definition stealable.h:25