19#include "pw_function/function.h"
20#include "pw_span/span.h"
22namespace pw::allocator::internal {
34 static Chunk* FromBytes(std::byte* ptr) {
35 return std::launder(
reinterpret_cast<Chunk*
>(ptr));
38 const std::byte* AsBytes()
const {
39 return std::launder(
reinterpret_cast<const std::byte*
>(
this));
42 std::byte* AsBytes() {
43 return std::launder(
reinterpret_cast<std::byte*
>(
this));
67 void Init(
size_t chunk_size = std::numeric_limits<size_t>::max());
70 static void Init(span<Bucket> buckets,
size_t min_chunk_size);
72 size_t chunk_size()
const {
return chunk_size_; }
74 bool empty()
const {
return sentinel_.next == &sentinel_; }
84 void Add(std::byte* ptr);
107 static std::byte*
Remove(std::byte* ptr);
Bucket()
Constructs a bucket with an unbounded chunk size.
std::byte * RemoveIf(const Function< bool(const std::byte *)> &cond)
Bucket(size_t chunk_size)
void Visit(const Function< void(const std::byte *)> &visitor) const
Applies the given function to each chunk in the bucket.
static std::byte * Remove(std::byte *ptr)
static void Init(span< Bucket > buckets, size_t min_chunk_size)
Creates a list of buckets, with each twice as large as the one before it.
fit::function_impl< inline_target_size, !function_internal::config::kEnableDynamicAllocation, FunctionType, Allocator > Function
Definition: function.h:63