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 {
25template <
typename OffsetType>
26using FirstFitBlock = DetailedBlock<OffsetType, SequencedItem>;
38template <
typename BlockType = FirstFitBlock<u
intptr_t>>
61 bucket_.set_threshold(threshold);
65 void set_threshold(
size_t threshold) { bucket_.set_threshold(threshold); }
70 BlockType* block = bucket_.RemoveCompatible(layout);
71 if (block ==
nullptr) {
74 if (layout.size() < bucket_.threshold()) {
75 return BlockType::AllocLast(std::move(block), layout);
77 return BlockType::AllocFirst(std::move(block), layout);
83 std::ignore = bucket_.Remove(block);
88 std::ignore = bucket_.Add(block);
Definition: block_allocator.h:104
void Init(ByteSpan region)
Definition: block_allocator.h:281
Definition: first_fit.h:39
FirstFitAllocator(ByteSpan region)
Definition: first_fit.h:51
void ReserveBlock(BlockType &block) override
Definition: first_fit.h:82
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:65
BlockResult< BlockType > ChooseBlock(Layout layout) override
Definition: first_fit.h:69
void RecycleBlock(BlockType &block) override
Definition: first_fit.h:87
FirstFitAllocator(ByteSpan region, size_t threshold)
Definition: first_fit.h:59
Definition: sequenced.h:44