join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::IoRingBuffer Class Reference

pool of buffers provided to the I/O backend. More...

#include <io_ring_buffer.hpp>

Public Member Functions

 IoRingBuffer () noexcept=default
 create instance.
 
 IoRingBuffer (const IoRingBuffer &other)=delete
 copy constructor.
 
IoRingBufferoperator= (const IoRingBuffer &other)=delete
 copy assignment operator.
 
 ~IoRingBuffer ()
 destroy instance.
 
template<size_t Count, size_t Size>
int registerBuffer (uint16_t group, LocalMem::Allocator< Count, Size > &arena)
 provide the arena buffers to the backend.
 
int unregisterBuffer () noexcept
 withdraw the buffers and give them back to the arena.
 
int select () noexcept
 take a free buffer.
 
void recycle (uint16_t bid) noexcept
 give a buffer back.
 
void bind () noexcept
 bind an operation to this buffer ring.
 
void unbind () noexcept
 unbind an operation from this buffer ring.
 
bool armed () const noexcept
 check whether operations are still bound to this buffer ring.
 
void * get (uint16_t bid) const noexcept
 get the address of a buffer.
 
uint16_t group () const noexcept
 get the buffer group id.
 
uint32_t size () const noexcept
 get the size of a buffer.
 
uint16_t count () const noexcept
 get the number of buffers.
 

Detailed Description

pool of buffers provided to the I/O backend.

Constructor & Destructor Documentation

◆ IoRingBuffer() [1/2]

join::IoRingBuffer::IoRingBuffer ( )
defaultnoexcept

create instance.

◆ IoRingBuffer() [2/2]

join::IoRingBuffer::IoRingBuffer ( const IoRingBuffer & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ ~IoRingBuffer()

join::IoRingBuffer::~IoRingBuffer ( )
inline

destroy instance.

Member Function Documentation

◆ armed()

bool join::IoRingBuffer::armed ( ) const
inlinenoexcept

check whether operations are still bound to this buffer ring.

Returns
true if at least one operation is bound.

◆ bind()

void join::IoRingBuffer::bind ( )
inlinenoexcept

bind an operation to this buffer ring.

◆ count()

uint16_t join::IoRingBuffer::count ( ) const
inlinenoexcept

get the number of buffers.

Returns
number of buffers.

◆ get()

void * join::IoRingBuffer::get ( uint16_t bid) const
inlinenoexcept

get the address of a buffer.

Parameters
bidbuffer index.
Returns
pointer to the buffer.

◆ group()

uint16_t join::IoRingBuffer::group ( ) const
inlinenoexcept

get the buffer group id.

Returns
buffer group id.

◆ operator=()

IoRingBuffer & join::IoRingBuffer::operator= ( const IoRingBuffer & other)
delete

copy assignment operator.

Parameters
otherother object to copy.
Returns
this.

◆ recycle()

void join::IoRingBuffer::recycle ( uint16_t bid)
inlinenoexcept

give a buffer back.

Parameters
bidbuffer index.

◆ registerBuffer()

template<size_t Count, size_t Size>
int join::IoRingBuffer::registerBuffer ( uint16_t group,
LocalMem::Allocator< Count, Size > & arena )

provide the arena buffers to the backend.

Parameters
groupbuffer group id.
arenaarena owning the buffers, reserved until unregistered, must outlive this object.
Returns
0 on success, -1 on failure.
Exceptions
std::system_errorif the descriptor ring cannot be mapped.

MIT License

Copyright (c) 2026 Mathieu Rabine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

◆ select()

int join::IoRingBuffer::select ( )
inlinenoexcept

take a free buffer.

Returns
buffer index, or -1 if none is available.

◆ size()

uint32_t join::IoRingBuffer::size ( ) const
inlinenoexcept

get the size of a buffer.

Returns
size of a buffer in bytes.

◆ unbind()

void join::IoRingBuffer::unbind ( )
inlinenoexcept

unbind an operation from this buffer ring.

◆ unregisterBuffer()

int join::IoRingBuffer::unregisterBuffer ( )
inlinenoexcept

withdraw the buffers and give them back to the arena.

Returns
0 on success, -1 on failure.

The documentation for this class was generated from the following files: