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

multiple producer single consumer ring buffer. More...

#include <queue.hpp>

Public Types

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

Static Public Member Functions

static int tryPush (Segment *segment, const Type &element, uint64_t &, uint64_t, 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 &, 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 &, 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 &, 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::Mpsc< Type, Backend >

multiple producer single consumer ring buffer.

Member Typedef Documentation

◆ Queue

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

◆ Segment

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

Member Function Documentation

◆ tryPop() [1/2]

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

try to pop element from the ring buffer.

Parameters
segmentshared memory segment.
elementoutput element.
cachedHeadconsumer-side cached index (not used).
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::Mpsc< Type, Backend >::tryPop ( Segment * segment,
Type * elements,
size_t size,
uint64_t & ,
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.
cachedHeadconsumer-side cached index (not used).
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::Mpsc< Type, Backend >::tryPush ( Segment * segment,
const Type & element,
uint64_t & ,
uint64_t ,
uint64_t mask )
inlinestaticnoexcept

try to push element into the ring buffer.

Parameters
segmentshared memory segment.
elementelement to push.
cachedTailproducer-side cached index (not used).
capacitymemory segment capacity (not used).
maskbit mask for fast modulo.
Returns
0 on success, -1 otherwise.

◆ tryPush() [2/2]

template<typename Type , typename Backend >
static ssize_t join::Mpsc< Type, Backend >::tryPush ( Segment * segment,
const Type * elements,
size_t size,
uint64_t & ,
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.
cachedTailproducer-side cached index (not used).
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: