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
 
using Slot
 
using Segment = QueueSegment<Type, Slot>
 

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.
 
ssize_t tryPush (const Type *elements, size_t size) noexcept
 try to push multiple elements into the ring buffer.
 
int push (const Type &element) noexcept
 push element into the ring buffer.
 
int push (const Type *elements, size_t size) noexcept
 push multiple elements into the ring buffer.
 
int tryPop (Type &element) noexcept
 try to pop element from the ring buffer.
 
ssize_t tryPop (Type *elements, size_t size) noexcept
 try to pop multiple elements from the ring buffer.
 
int pop (Type &element) noexcept
 pop element from the ring buffer.
 
int pop (Type *elements, size_t size) noexcept
 pop multiple elements 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 mlock () const noexcept
 lock memory in RAM.
 

Detailed Description

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

queue base class.

Member Typedef Documentation

◆ Segment

template<typename Type , typename Backend , typename SyncPolicy >
using join::BasicQueue< Type, Backend, SyncPolicy >::Segment = QueueSegment<Type, Slot>

◆ Slot

template<typename Type , typename Backend , typename SyncPolicy >
using join::BasicQueue< Type, Backend, SyncPolicy >::Slot
Initial value:
typename std::conditional<needs_seq<SyncPolicy>::value, QueueSlotFull<Type>, QueueSlotLight<Type>>::type

◆ 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 )
inlineexplicit

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.

◆ 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() [1/2]

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.

◆ pop() [2/2]

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::pop ( Type * elements,
size_t size )
inlinenoexcept

pop multiple elements from the ring buffer.

Parameters
elementspointer to the output buffer.
sizenumber of elements to pop.
Returns
0 on success, -1 otherwise.

◆ push() [1/2]

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.

◆ push() [2/2]

template<typename Type , typename Backend , typename SyncPolicy >
int join::BasicQueue< Type, Backend, SyncPolicy >::push ( const Type * elements,
size_t size )
inlinenoexcept

push multiple elements into the ring buffer.

Parameters
elementspointer to the first element.
sizenumber of elements to push.
Returns
0 on success, -1 otherwise.

◆ tryPop() [1/2]

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.

◆ tryPop() [2/2]

template<typename Type , typename Backend , typename SyncPolicy >
ssize_t join::BasicQueue< Type, Backend, SyncPolicy >::tryPop ( Type * elements,
size_t size )
inlinenoexcept

try to pop multiple elements from the ring buffer.

Parameters
elementspointer to the output buffer.
sizemaximum number of elements to pop.
Returns
number of elements successfully popped, -1 otherwise.

◆ tryPush() [1/2]

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.

◆ tryPush() [2/2]

template<typename Type , typename Backend , typename SyncPolicy >
ssize_t join::BasicQueue< Type, Backend, SyncPolicy >::tryPush ( const Type * elements,
size_t size )
inlinenoexcept

try to push multiple elements into the ring buffer.

Parameters
elementspointer to the first element.
sizenumber of elements to push.
Returns
number of elements successfully pushed, -1 otherwise.

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