join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::Spsc Class Reference

single producer single consumer ring buffer policy. More...

#include <shared.hpp>

Inheritance diagram for join::Spsc:

Public Types

using Producer = BasicProducer <Spsc>
 
using Consumer = BasicConsumer <Spsc>
 
using Endpoint = BasicEndpoint <Spsc, Spsc>
 

Public Member Functions

constexpr Spsc () noexcept=default
 construct the single producer single consumer ring buffer policy by default.
 
virtual int tryPush (SharedSegment *segment, const void *element) const noexcept
 try to push element into the ring buffer.
 
int push (SharedSegment *segment, const void *element) const noexcept
 push element into the ring buffer.
 
template<class Rep , class Period >
int timedPush (SharedSegment *segment, const void *element, std::chrono::duration< Rep, Period > timeout) const noexcept
 try to push element into the ring buffer until timeout expire.
 
virtual int tryPop (SharedSegment *segment, void *element) const noexcept
 try to pop element from the ring buffer.
 
int pop (SharedSegment *segment, void *element) const noexcept
 pop element from the ring buffer.
 
template<class Rep , class Period >
int timedPop (SharedSegment *segment, void *element, std::chrono::duration< Rep, Period > timeout) const noexcept
 try to pop element from the ring buffer until timeout expire.
 
uint64_t pending (SharedSegment *segment) const noexcept
 get the number of pending elements for reading.
 
uint64_t available (SharedSegment *segment) const noexcept
 get the number of available slots for writing.
 
bool full (SharedSegment *segment) const noexcept
 check if the ring buffer is full.
 
bool empty (SharedSegment *segment) const noexcept
 check if the ring buffer is empty.
 

Detailed Description

single producer single consumer ring buffer policy.

Member Typedef Documentation

◆ Consumer

◆ Endpoint

◆ Producer

Constructor & Destructor Documentation

◆ Spsc()

join::Spsc::Spsc ( )
constexprdefaultnoexcept

construct the single producer single consumer ring buffer policy by default.

Member Function Documentation

◆ available()

uint64_t join::Spsc::available ( SharedSegment * segment) const
inlinenoexcept

get the number of available slots for writing.

Parameters
segmentshared memory segment.
Returns
number of slots available in the ring buffer.

◆ empty()

bool join::Spsc::empty ( SharedSegment * segment) const
inlinenoexcept

check if the ring buffer is empty.

Parameters
segmentshared memory segment.
Returns
true if empty, false otherwise.

◆ full()

bool join::Spsc::full ( SharedSegment * segment) const
inlinenoexcept

check if the ring buffer is full.

Parameters
segmentshared memory segment.
Returns
true if full, false otherwise.

◆ pending()

uint64_t join::Spsc::pending ( SharedSegment * segment) const
inlinenoexcept

get the number of pending elements for reading.

Parameters
segmentshared memory segment.
Returns
number of elements pending in the ring buffer.

◆ pop()

int join::Spsc::pop ( SharedSegment * segment,
void * element ) const
inlinenoexcept

pop element from the ring buffer.

Parameters
segmentshared memory segment.
elementpointer to output element.
Returns
0 on success, -1 otherwise.

◆ push()

int join::Spsc::push ( SharedSegment * segment,
const void * element ) const
inlinenoexcept

push element into the ring buffer.

Parameters
segmentshared memory segment.
elementpointer to element to push.
Returns
0 on success, -1 otherwise.

◆ timedPop()

template<class Rep , class Period >
int join::Spsc::timedPop ( SharedSegment * segment,
void * element,
std::chrono::duration< Rep, Period > timeout ) const
inlinenoexcept

try to pop element from the ring buffer until timeout expire.

Parameters
segmentshared memory segment.
elementpointer to output element.
timeouttimeout.
Returns
0 on success, -1 otherwise.

◆ timedPush()

template<class Rep , class Period >
int join::Spsc::timedPush ( SharedSegment * segment,
const void * element,
std::chrono::duration< Rep, Period > timeout ) const
inlinenoexcept

try to push element into the ring buffer until timeout expire.

Parameters
segmentshared memory segment.
elementpointer to element to push.
timeouttimeout.
Returns
0 on success, -1 otherwise.

◆ tryPop()

virtual int join::Spsc::tryPop ( SharedSegment * segment,
void * element ) const
inlinevirtualnoexcept

try to pop element from the ring buffer.

Parameters
segmentshared memory segment.
elementpointer to output element.
Returns
0 on success, -1 otherwise.

Reimplemented in join::Mpmc.

◆ tryPush()

virtual int join::Spsc::tryPush ( SharedSegment * segment,
const void * element ) const
inlinevirtualnoexcept

try to push element into the ring buffer.

Parameters
segmentshared memory segment.
elementpointer to element to push.
Returns
0 on success, -1 otherwise.

Reimplemented in join::Mpsc.


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