join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::Mpmc< Type, Backend > Struct Template Reference

multiple producer multiple consumer ring buffer. More...

#include <queue.hpp>

Public Types

using Queue = BasicQueue<Type, Backend, Mpmc>
 
using Segment = QueueSegment<Type, QueueSlotFull<Type>>
 

Static Public Member Functions

static int tryPush (Segment *segment, const Type &element, uint64_t capacity, uint64_t mask) noexcept
 try to push element into the ring buffer.
 
static ssize_t tryPush (Segment *segment, const Type *elements, size_t size, uint64_t capacity, uint64_t mask) noexcept
 try to push multiple elements into the ring buffer.
 
static int tryPop (Segment *segment, Type &element, uint64_t capacity, uint64_t mask) noexcept
 try to pop element from the ring buffer.
 
static ssize_t tryPop (Segment *segment, Type *elements, size_t size, uint64_t capacity, uint64_t mask) noexcept
 try to pop multiple elements from the ring buffer.
 

Detailed Description

template<typename Type, typename Backend>
struct join::Mpmc< Type, Backend >

multiple producer multiple consumer ring buffer.

Member Typedef Documentation

◆ Queue

template<typename Type , typename Backend >
using join::Mpmc< Type, Backend >::Queue = BasicQueue<Type, Backend, Mpmc>

◆ Segment

template<typename Type , typename Backend >
using join::Mpmc< Type, Backend >::Segment = QueueSegment<Type, QueueSlotFull<Type>>

Member Function Documentation

◆ tryPop() [1/2]

template<typename Type , typename Backend >
static int join::Mpmc< Type, Backend >::tryPop ( Segment * segment,
Type & element,
uint64_t capacity,
uint64_t mask )
inlinestaticnoexcept

try to pop element from the ring buffer.

Parameters
segmentshared memory segment.
elementoutput element.
capacitymemory segment capacity.
maskbit mask for fast modulo.
Returns
0 on success, -1 otherwise.

◆ tryPop() [2/2]

template<typename Type , typename Backend >
static ssize_t join::Mpmc< Type, Backend >::tryPop ( Segment * segment,
Type * elements,
size_t size,
uint64_t capacity,
uint64_t mask )
inlinestaticnoexcept

try to pop multiple elements from the ring buffer.

Parameters
segmentshared memory segment.
elementspointer to the output buffer.
sizemaximum number of elements to pop.
capacitymemory segment capacity.
maskbit mask for fast modulo.
Returns
number of elements successfully popped, -1 otherwise.

◆ tryPush() [1/2]

template<typename Type , typename Backend >
static int join::Mpmc< Type, Backend >::tryPush ( Segment * segment,
const Type & element,
uint64_t capacity,
uint64_t mask )
inlinestaticnoexcept

try to push element into the ring buffer.

Parameters
segmentshared memory segment.
elementelement to push.
capacitymemory segment capacity.
maskbit mask for fast modulo.
Returns
0 on success, -1 otherwise.

◆ tryPush() [2/2]

template<typename Type , typename Backend >
static ssize_t join::Mpmc< Type, Backend >::tryPush ( Segment * segment,
const Type * elements,
size_t size,
uint64_t capacity,
uint64_t mask )
inlinestaticnoexcept

try to push multiple elements into the ring buffer.

Parameters
segmentshared memory segment.
elementspointer to the first element.
sizenumber of elements to push.
capacitymemory segment capacity.
maskbit mask for fast modulo.
Returns
number of elements successfully pushed, -1 otherwise.

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