17 [[nodiscard]]
static void*
allocate(std::size_t size) {
18 return ::operator
new(size);
21 static void deallocate(
void* ptr, [[maybe_unused]] std::size_t size)
noexcept {
22 ::operator
delete(ptr);
31template <std::
size_t MaxFrames = 16, std::
size_t FrameSize = 256>
37 struct alignas(std::max_align_t)
Slot {
42 [[nodiscard]]
static void*
allocate(std::size_t size)
noexcept {
43 if (size > FrameSize) {
47 for (
auto& slot : _slots) {
50 return static_cast<void*
>(slot.storage);
56 static void deallocate(
void* ptr, std::size_t )
noexcept {
61 for (
auto& slot : _slots) {
62 if (
static_cast<void*
>(slot.storage) == ptr) {
71 std::size_t count = 0;
72 for (
const auto& slot : _slots) {
82 for (
auto& slot : _slots) {
88 static inline std::array<Slot, MaxFrames> _slots{};
92template <std::
size_t MaxFrames = 16, std::
size_t FrameSize = 256>
96 [[nodiscard]]
static void*
allocate(std::size_t size) {
99#if defined(__cpp_exceptions) || defined(__EXCEPTIONS)
100 throw std::bad_alloc();
108 static void deallocate(
void* ptr, std::size_t size)
noexcept {
Statically-allocated fixed-capacity memory pool for coroutine state frames. Eliminates heap allocatio...
Definition FramePool.hpp:32
static void * allocate(std::size_t size) noexcept
Definition FramePool.hpp:42
static constexpr std::size_t max_frames
Definition FramePool.hpp:34
static void deallocate(void *ptr, std::size_t) noexcept
Definition FramePool.hpp:56
static void reset() noexcept
Reset all pool slots to available state.
Definition FramePool.hpp:81
static constexpr std::size_t frame_size
Definition FramePool.hpp:35
static std::size_t activeCount() noexcept
Number of active frames currently allocated from the pool.
Definition FramePool.hpp:70
Definition AsyncEvent.hpp:14
Default heap allocator policy for C++20 coroutine frames (HALO-eligible).
Definition FramePool.hpp:16
static void deallocate(void *ptr, std::size_t size) noexcept
Definition FramePool.hpp:21
static void * allocate(std::size_t size)
Definition FramePool.hpp:17
Allocator policy adapter wrapping a StaticFramePool.
Definition FramePool.hpp:93
static void * allocate(std::size_t size)
Definition FramePool.hpp:96
static void deallocate(void *ptr, std::size_t size) noexcept
Definition FramePool.hpp:108
Definition FramePool.hpp:37
std::byte storage[FrameSize]
Definition FramePool.hpp:38
bool inUse
Definition FramePool.hpp:39