25#ifndef JOIN_CORE_IO_RING_BUFFER_HPP
26#define JOIN_CORE_IO_RING_BUFFER_HPP
39#ifdef JOIN_HAS_IO_URING
51#ifdef JOIN_HAS_IO_URING
95 template <
size_t Count,
size_t Size>
104#ifndef JOIN_HAS_IO_URING
116 void recycle (uint16_t bid)
noexcept;
123 _armed.fetch_add (1, std::memory_order_relaxed);
131 _armed.fetch_sub (1, std::memory_order_release);
140 return _armed.load (std::memory_order_acquire) != 0;
148 void*
get (uint16_t bid)
const noexcept
150 return _base + (bid * _size);
166 uint32_t
size () const noexcept
182 static constexpr uint16_t _none = UINT16_MAX;
184#ifdef JOIN_HAS_IO_URING
186 io_uring* _uring =
nullptr;
192 io_uring_buf_ring* _ring =
nullptr;
195 uint16_t _free = _none;
199 char* _base =
nullptr;
214 std::atomic<uint32_t> _armed{0};
218#ifdef JOIN_HAS_IO_URING
memory arena owning backend and managing one or more pools.
Definition memory.hpp:53
fixed-capacity move-only allocation-free alternative to std::function.
Definition function.hpp:44
pool of buffers provided to the I/O backend.
Definition io_ring_buffer.hpp:49
uint32_t size() const noexcept
get the size of a buffer.
Definition io_ring_buffer.hpp:166
IoRingBuffer & operator=(const IoRingBuffer &other)=delete
copy assignment operator.
void bind() noexcept
bind an operation to this buffer ring.
Definition io_ring_buffer.hpp:121
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
~IoRingBuffer()
destroy instance.
Definition io_ring_buffer.hpp:83
IoRingBuffer(const IoRingBuffer &other)=delete
copy constructor.
int unregisterBuffer() noexcept
withdraw the buffers and give them back to the arena.
Definition io_ring_buffer_epoll.hpp:69
IoRingBuffer() noexcept=default
create instance.
bool armed() const noexcept
check whether operations are still bound to this buffer ring.
Definition io_ring_buffer.hpp:138
void unbind() noexcept
unbind an operation from this buffer ring.
Definition io_ring_buffer.hpp:129
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
uint16_t count() const noexcept
get the number of buffers.
Definition io_ring_buffer.hpp:175
local anonymous memory provider.
Definition memory.hpp:122
Definition acceptor.hpp:32