iceoryx_doc  1.0.1
Classes | Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
iox::concurrent::IndexQueue< Capacity, ValueType > Class Template Reference

lockfree queue capable of storing indices 0,1,... Capacity-1 More...

#include <index_queue.hpp>

Collaboration diagram for iox::concurrent::IndexQueue< Capacity, ValueType >:
Collaboration graph
[legend]

Classes

struct  ConstructEmpty_t
 
struct  ConstructFull_t
 

Public Types

using value_t = ValueType
 

Public Member Functions

 IndexQueue (const IndexQueue &)=delete
 
 IndexQueue (IndexQueue &&)=delete
 
IndexQueueoperator= (const IndexQueue &)=delete
 
IndexQueueoperator= (IndexQueue &&)=delete
 
 IndexQueue (ConstructEmpty_t=ConstructEmpty) noexcept
 constructs an empty IndexQueue
 
 IndexQueue (ConstructFull_t) noexcept
 constructs IndexQueue filled with all indices 0,1,...capacity-1
 
constexpr uint64_t capacity () const noexcept
 get the capacity of the IndexQueue More...
 
bool empty () const noexcept
 check whether the queue is empty More...
 
void push (const ValueType index) noexcept
 push index into the queue in FIFO order More...
 
cxx::optional< ValueType > pop () noexcept
 pop an index from the queue in FIFO order if the queue not empty More...
 
cxx::optional< ValueType > popIfFull () noexcept
 pop an index from the queue in FIFO order if the queue is full More...
 
cxx::optional< ValueType > popIfSizeIsAtLeast (uint64_t size) noexcept
 pop an index from the queue in FIFO order if the queue contains at least a specified number number of elements More...
 

Static Public Attributes

static constexpr ConstructFull_t ConstructFull {}
 
static constexpr ConstructEmpty_t ConstructEmpty {}
 

Friends

template<typename ElementType , uint64_t Cap>
class LockFreeQueue
 
template<typename ElementType , uint64_t Cap>
class ResizeableLockFreeQueue
 

Detailed Description

template<uint64_t Capacity, typename ValueType = uint64_t>
class iox::concurrent::IndexQueue< Capacity, ValueType >

lockfree queue capable of storing indices 0,1,... Capacity-1

Member Function Documentation

◆ capacity()

template<uint64_t Capacity, typename ValueType >
constexpr uint64_t iox::concurrent::IndexQueue< Capacity, ValueType >::capacity
constexprnoexcept

get the capacity of the IndexQueue

Returns
capacity of the IndexQueue threadsafe, lockfree

◆ empty()

template<uint64_t Capacity, typename ValueType >
bool iox::concurrent::IndexQueue< Capacity, ValueType >::empty
noexcept

check whether the queue is empty

Returns
true iff the queue is empty note that if the queue is used concurrently it might not be empty anymore after the call (but it was at some point during the call)

◆ pop()

template<uint64_t Capacity, typename ValueType >
cxx::optional< ValueType > iox::concurrent::IndexQueue< Capacity, ValueType >::pop
noexcept

pop an index from the queue in FIFO order if the queue not empty

Returns
index if the queue was is empty, nullopt oterwise

◆ popIfFull()

template<uint64_t Capacity, typename ValueType >
cxx::optional< ValueType > iox::concurrent::IndexQueue< Capacity, ValueType >::popIfFull
noexcept

pop an index from the queue in FIFO order if the queue is full

Returns
index if the queue was full, nullopt otherwise

◆ popIfSizeIsAtLeast()

template<uint64_t Capacity, typename ValueType >
cxx::optional< ValueType > iox::concurrent::IndexQueue< Capacity, ValueType >::popIfSizeIsAtLeast ( uint64_t  size)
noexcept

pop an index from the queue in FIFO order if the queue contains at least a specified number number of elements

Parameters
sizethe number of elements needed to successfully perform the pop
Returns
index if the queue contains size elements, nullopt otherwise

◆ push()

template<uint64_t Capacity, typename ValueType >
void iox::concurrent::IndexQueue< Capacity, ValueType >::push ( const ValueType  index)
noexcept

push index into the queue in FIFO order

Parameters
indexto be pushed note that do the way it is supposed to be used we cannot overflow (the number of indices available is bounded and the capacity is large enough to hold them all)

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