18#include "pw_allocator/block/detailed_block.h"
19#include "pw_allocator/block_allocator.h"
20#include "pw_allocator/bucket/sequenced.h"
22namespace pw::allocator {
27template <
typename OffsetType>
40template <
typename BlockType = FirstFitBlock<u
intptr_t>>
64 void set_threshold(
size_t threshold) { bucket_.set_threshold(threshold); }
75 std::ignore = bucket_.Remove(block);
80 std::ignore = bucket_.Add(block);
90template <
typename BlockType>
94 bucket_.set_threshold(threshold);
97template <
typename BlockType>
99 const BlockType* largest = bucket_.FindLargest();
100 return largest ==
nullptr ? 0 : largest->InnerSize();
103template <
typename BlockType>
106 BlockType* block = bucket_.RemoveCompatible(layout);
107 if (block ==
nullptr) {
110 if (layout.size() < bucket_.threshold()) {
111 return BlockType::AllocLast(std::move(block), layout);
113 return BlockType::AllocFirst(std::move(block), layout);
static constexpr Status NotFound()
Definition: status.h:190
Definition: block_allocator.h:98
void Init(ByteSpan region)
Definition: block_allocator.h:303
Definition: detailed_block.h:88
Definition: first_fit.h:41
FirstFitAllocator(ByteSpan region)
Definition: first_fit.h:53
void ReserveBlock(BlockType &block) override
Definition: first_fit.h:74
constexpr FirstFitAllocator()=default
Constexpr constructor. Callers must explicitly call Init.
void set_threshold(size_t threshold)
Sets the threshold value for which requests are considered "large".
Definition: first_fit.h:64
size_t DoGetMaxAllocatable() override
Definition: first_fit.h:98
BlockResult< BlockType > ChooseBlock(Layout layout) override
Definition: first_fit.h:104
void RecycleBlock(BlockType &block) override
Definition: first_fit.h:79
FirstFitAllocator(ByteSpan region, size_t threshold)
Definition: first_fit.h:91
Definition: sequenced.h:46