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>>
63 bucket_.set_threshold(threshold);
67 void set_threshold(
size_t threshold) { bucket_.set_threshold(threshold); }
72 const BlockType* largest = bucket_.FindLargest();
73 return largest ==
nullptr ? 0 : largest->InnerSize();
78 BlockType* block = bucket_.RemoveCompatible(layout);
79 if (block ==
nullptr) {
82 if (layout.size() < bucket_.threshold()) {
83 return BlockType::AllocLast(std::move(block), layout);
85 return BlockType::AllocFirst(std::move(block), layout);
91 std::ignore = bucket_.Remove(block);
96 std::ignore = bucket_.Add(block);
Definition: block_allocator.h:106
void Init(ByteSpan region)
Definition: block_allocator.h:310
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:90
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:67
size_t DoGetMaxAllocatable() override
Definition: first_fit.h:71
BlockResult< BlockType > ChooseBlock(Layout layout) override
Definition: first_fit.h:77
void RecycleBlock(BlockType &block) override
Definition: first_fit.h:95
FirstFitAllocator(ByteSpan region, size_t threshold)
Definition: first_fit.h:61
Definition: sequenced.h:46