29template <
size_t Count,
size_t Size>
32 static_assert (
isPow2 (Count),
"buffer count must be a power of two");
46 _base =
static_cast<char*
> (arena.
getPtr (0));
47 _release = [&arena] () {
55 for (uint16_t bid = 0; bid < _count - 1; ++bid)
57 *
static_cast<uint16_t*
> (
get (bid)) = bid + 1;
60 *
static_cast<uint16_t*
> (
get (_count - 1)) = _none;
99 _free = *
static_cast<uint16_t*
> (get (bid));
110 *
static_cast<uint16_t*
> (get (bid)) = _free;
memory arena owning backend and managing one or more pools.
Definition memory.hpp:53
void * getPtr(uint32_t idx) const noexcept
get the pointer to a chunk by index.
Definition allocator.hpp:510
bool reserveAll() noexcept
reserve all chunks of a pool at once.
Definition allocator.hpp:521
void releaseAll() noexcept
release all chunks of a pool at once.
Definition allocator.hpp:531
void recycle(uint16_t bid) noexcept
give a buffer back.
Definition io_ring_buffer_epoll.hpp:108
uint16_t group() const noexcept
get the buffer group id.
Definition io_ring_buffer.hpp:157
int unregisterBuffer() noexcept
withdraw the buffers and give them back to the arena.
Definition io_ring_buffer_epoll.hpp:69
int select() noexcept
take a free buffer.
Definition io_ring_buffer_epoll.hpp:91
void * get(uint16_t bid) const noexcept
get the address of a buffer.
Definition io_ring_buffer.hpp:148
int registerBuffer(uint16_t group, LocalMem::Allocator< Count, Size > &arena)
provide the arena buffers to the backend.
Definition io_ring_buffer_epoll.hpp:30
constexpr bool isPow2(uint64_t value) noexcept
check if a value is a power of two.
Definition utils.hpp:496
std::error_code make_error_code(join::Errc code) noexcept
Create an std::error_code object.
Definition error.cpp:195
#define JOIN_UNLIKELY(x)
Definition utils.hpp:46