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

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

#include <shared.hpp>

Inheritance diagram for join::Mpmc:
Collaboration diagram for join::Mpmc:

Public Types

using Producer = BasicProducer <Mpmc>
 
using Consumer = BasicConsumer <Mpmc>
 
using Endpoint = BasicEndpoint <Mpmc, Mpmc>
 
- Public Types inherited from join::Mpsc
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 Mpmc () noexcept=default
 construct the multiple producer multiple consumer ring buffer policy by default.
 
int tryPop (SharedSegment *segment, void *element) const noexcept override
 try to pop element from the ring buffer (lock-free for multiple consumers).
 
- Public Member Functions inherited from join::Mpsc
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.
 
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 multiple consumer ring buffer policy.

Member Typedef Documentation

◆ Consumer

◆ Endpoint

◆ Producer

Constructor & Destructor Documentation

◆ Mpmc()

join::Mpmc::Mpmc ( )
constexprdefaultnoexcept

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

Member Function Documentation

◆ tryPop()

int join::Mpmc::tryPop ( SharedSegment * segment,
void * element ) const
inlineoverridevirtualnoexcept

try to pop element from the ring buffer (lock-free for multiple consumers).

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

Reimplemented from join::Spsc.


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