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

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

#include <shared.hpp>

Inheritance diagram for join::Mpsc:
Collaboration diagram for join::Mpsc:

Public Types

using Producer = BasicProducer <Mpsc>
 
using Consumer = BasicConsumer <Mpsc>
 
using Endpoint = BasicEndpoint <Mpsc, Mpsc>
 
- Public Types inherited from join::Spsc
using Producer = BasicProducer <Spsc>
 
using Consumer = BasicConsumer <Spsc>
 
using Endpoint = BasicEndpoint <Spsc, Spsc>
 

Public Member Functions

constexpr Mpsc () noexcept=default
 construct the multiple producer single consumer ring buffer policy by default.
 
int tryPush (SharedSegment *segment, const void *element) const noexcept override
 try to push element into the ring buffer (lock-free for multiple producers).
 
- Public Member Functions inherited from join::Spsc
constexpr Spsc () noexcept=default
 construct the single producer single consumer ring buffer policy by default.
 
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

multiple producer single consumer ring buffer policy.

Member Typedef Documentation

◆ Consumer

◆ Endpoint

◆ Producer

Constructor & Destructor Documentation

◆ Mpsc()

join::Mpsc::Mpsc ( )
constexprdefaultnoexcept

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

Member Function Documentation

◆ tryPush()

int join::Mpsc::tryPush ( SharedSegment * segment,
const void * element ) const
inlineoverridevirtualnoexcept

try to push element into the ring buffer (lock-free for multiple producers).

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

Reimplemented from join::Spsc.


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