join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicQueue< Type, Backend, SyncPolicy > Class Template Reference

queue base class. More...

#include <queue.hpp>

Public Types

using ValueType = Type
 

Public Member Functions

template<typename... Args>
 BasicQueue (uint64_t capacity, Args &&... args)
 create instance.
 
 BasicQueue (const BasicQueue &other)=delete
 copy constructor.
 
BasicQueueoperator= (const BasicQueue &other)=delete
 copy assignment operator.
 
 BasicQueue (BasicQueue &&other)=delete
 move constructor.
 
BasicQueueoperator= (BasicQueue &&other)=delete
 move assignment operator.
 
 ~BasicQueue () noexcept=default
 destroy queue instance.
 
int tryPush (const Type &element) noexcept
 try to push element into ring buffer.
 
int push (const Type &element) noexcept
 push element into the ring buffer.
 
int tryPop (Type &element) noexcept
 try to pop element from the ring buffer.
 
int pop (Type &element) noexcept
 pop element from the ring buffer.
 
uint64_t pending () const noexcept
 get the number of pending elements for reading.
 
uint64_t available () const noexcept
 get the number of available slots for writing.
 
bool full () const noexcept
 check if the ring buffer is full.
 
bool empty () const noexcept
 check if the ring buffer is empty.
 
int mbind (int numa) const noexcept
 bind memory to a NUMA node.
 
int mlock () const noexcept
 lock memory in RAM.
 

Static Protected Member Functions

static uint64_t roundPow2 (uint64_t v) noexcept
 round up to next power of 2.
 

Protected Attributes

uint64_t _capacity = 0
 memory segment capacity.
 
uint64_t _elementSize = 0
 memory segment element size.
 
uint64_t _totalSize = 0
 total memory size.
 
Backend _backend
 memory segment backend.
 
SyncPolicy _policy
 memory segment sync policy.
 
QueueSegment< Type > * _segment = nullptr
 shared memory segment.
 

Detailed Description

template<typename Type, typename Backend, typename SyncPolicy>
class join::BasicQueue< Type, Backend, SyncPolicy >

queue base class.

Member Typedef Documentation

◆ ValueType

template<typename Type , typename Backend , typename SyncPolicy >
using join::BasicQueue< Type, Backend, SyncPolicy >::ValueType = Type

Constructor & Destructor Documentation

◆ BasicQueue() [1/3]

template<typename Type , typename Backend , typename SyncPolicy >
template<typename... Args>
join::BasicQueue< Type, Backend, SyncPolicy >::BasicQueue ( uint64_t capacity,
Args &&... args )
inline

create instance.

Parameters
capacityqueue capacity.
argsbackend args.

◆ BasicQueue() [2/3]

template<typename Type , typename Backend , typename SyncPolicy >
join::BasicQueue< Type, Backend, SyncPolicy >::BasicQueue ( const BasicQueue< Type, Backend, SyncPolicy > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ BasicQueue() [3/3]

template<typename Type , typename Backend , typename SyncPolicy >
join::BasicQueue< Type, Backend, SyncPolicy >::BasicQueue ( BasicQueue< Type, Backend, SyncPolicy > && other)
delete

move constructor.

Parameters
otherother object to move.

◆ ~BasicQueue()

template<typename Type , typename Backend , typename SyncPolicy >
join::BasicQueue< Type, Backend, SyncPolicy >::~BasicQueue ( )
defaultnoexcept

destroy queue instance.

Member Function Documentation

◆ available()

template<typename Type , typename Backend , typename SyncPolicy >
uint64_t join::BasicQueue< Type, Backend, SyncPolicy >::available ( ) const
inlinenoexcept

get the number of available slots for writing.

Returns
number of slots available in the ring buffer.

◆ empty()

template<typename Type , typename Backend , typename SyncPolicy >
bool join::BasicQueue< Type, Backend, SyncPolicy >::empty ( ) const
inlinenoexcept

check if the ring buffer is empty.

Returns
true if empty, false otherwise.

◆ full()

template<typename Type , typename Backend , typename SyncPolicy >
bool join::BasicQueue< Type, Backend, SyncPolicy >::full ( ) const
inlinenoexcept

check if the ring buffer is full.

Returns
true if full, false otherwise.

◆ mbind()

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::mbind ( int numa) const
inlinenoexcept

bind memory to a NUMA node.

Parameters
numaNUMA node ID.
Returns
0 on success, -1 on failure.

◆ mlock()

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::mlock ( ) const
inlinenoexcept

lock memory in RAM.

Returns
0 on success, -1 on failure.

◆ operator=() [1/2]

template<typename Type , typename Backend , typename SyncPolicy >
BasicQueue & join::BasicQueue< Type, Backend, SyncPolicy >::operator= ( BasicQueue< Type, Backend, SyncPolicy > && other)
delete

move assignment operator.

Parameters
otherother object to move.
Returns
this.

◆ operator=() [2/2]

template<typename Type , typename Backend , typename SyncPolicy >
BasicQueue & join::BasicQueue< Type, Backend, SyncPolicy >::operator= ( const BasicQueue< Type, Backend, SyncPolicy > & other)
delete

copy assignment operator.

Parameters
otherother object to copy.
Returns
this.

◆ pending()

template<typename Type , typename Backend , typename SyncPolicy >
uint64_t join::BasicQueue< Type, Backend, SyncPolicy >::pending ( ) const
inlinenoexcept

get the number of pending elements for reading.

Returns
number of elements pending in the ring buffer.

◆ pop()

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::pop ( Type & element)
inlinenoexcept

pop element from the ring buffer.

Parameters
elementoutput element.
Returns
0 on success, -1 otherwise.

◆ push()

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::push ( const Type & element)
inlinenoexcept

push element into the ring buffer.

Parameters
elementelement to push.
Returns
0 on success, -1 otherwise.

◆ roundPow2()

template<typename Type , typename Backend , typename SyncPolicy >
static uint64_t join::BasicQueue< Type, Backend, SyncPolicy >::roundPow2 ( uint64_t v)
inlinestaticprotectednoexcept

round up to next power of 2.

Parameters
vinput value.
Returns
smallest power of 2 >= v.

◆ tryPop()

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::tryPop ( Type & element)
inlinenoexcept

try to pop element from the ring buffer.

Parameters
elementoutput element.
Returns
0 on success, -1 otherwise.

◆ tryPush()

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::tryPush ( const Type & element)
inlinenoexcept

try to push element into ring buffer.

Parameters
elementelement to push.
Returns
0 on success, -1 otherwise.

Member Data Documentation

◆ _backend

template<typename Type , typename Backend , typename SyncPolicy >
Backend join::BasicQueue< Type, Backend, SyncPolicy >::_backend
protected

memory segment backend.

◆ _capacity

template<typename Type , typename Backend , typename SyncPolicy >
uint64_t join::BasicQueue< Type, Backend, SyncPolicy >::_capacity = 0
protected

memory segment capacity.

◆ _elementSize

template<typename Type , typename Backend , typename SyncPolicy >
uint64_t join::BasicQueue< Type, Backend, SyncPolicy >::_elementSize = 0
protected

memory segment element size.

◆ _policy

template<typename Type , typename Backend , typename SyncPolicy >
SyncPolicy join::BasicQueue< Type, Backend, SyncPolicy >::_policy
protected

memory segment sync policy.

◆ _segment

template<typename Type , typename Backend , typename SyncPolicy >
QueueSegment<Type>* join::BasicQueue< Type, Backend, SyncPolicy >::_segment = nullptr
protected

shared memory segment.

◆ _totalSize

template<typename Type , typename Backend , typename SyncPolicy >
uint64_t join::BasicQueue< Type, Backend, SyncPolicy >::_totalSize = 0
protected

total memory size.


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