Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::ipc::MpscProducer Class Reference

Multi-producer single-consumer - producer side. More...

#include <mpsc_shm.hpp>

Public Member Functions

 MpscProducer (MpscProducer &&other) noexcept
 
MpscProduceroperator= (MpscProducer &&other) noexcept
 
 MpscProducer (const MpscProducer &)=delete
 
MpscProduceroperator= (const MpscProducer &)=delete
 
 ~MpscProducer ()
 
void * claim (size_t want, uint32_t timeout_ns)
 Claim space in producer's ring.
 
void publish (size_t n)
 Publish data to producer's ring (rings doorbell)
 

Static Public Member Functions

static MpscProducer connect (const std::string &name, size_t producer_id)
 Connect to MPSC system as a producer.
 

Private Member Functions

 MpscProducer (SpscShm &&ring, int doorbell_fd, size_t doorbell_len, MpscDoorbell *doorbell, size_t producer_id)
 

Private Attributes

SpscShm ring_
 
int doorbell_fd_ = -1
 
size_t doorbell_len_ = 0
 
MpscDoorbelldoorbell_ = nullptr
 
size_t producer_id_ = 0
 

Detailed Description

Multi-producer single-consumer - producer side.

Connects to one SPSC ring and rings the shared doorbell when publishing.

Definition at line 113 of file mpsc_shm.hpp.

Constructor & Destructor Documentation

◆ MpscProducer() [1/3]

bb::ipc::MpscProducer::MpscProducer ( MpscProducer &&  other)
noexcept

Definition at line 283 of file mpsc_shm.cpp.

◆ MpscProducer() [2/3]

bb::ipc::MpscProducer::MpscProducer ( const MpscProducer )
delete

◆ ~MpscProducer()

bb::ipc::MpscProducer::~MpscProducer ( )

Definition at line 323 of file mpsc_shm.cpp.

◆ MpscProducer() [3/3]

bb::ipc::MpscProducer::MpscProducer ( SpscShm &&  ring,
int  doorbell_fd,
size_t  doorbell_len,
MpscDoorbell doorbell,
size_t  producer_id 
)
private

Definition at line 274 of file mpsc_shm.cpp.

Member Function Documentation

◆ claim()

void * bb::ipc::MpscProducer::claim ( size_t  want,
uint32_t  timeout_ns 
)

Claim space in producer's ring.

Parameters
wantBytes wanted
timeout_nsTimeout in nanoseconds
Returns
Pointer to buffer, or nullptr on timeout

Definition at line 364 of file mpsc_shm.cpp.

◆ connect()

MpscProducer bb::ipc::MpscProducer::connect ( const std::string &  name,
size_t  producer_id 
)
static

Connect to MPSC system as a producer.

Parameters
nameBase name for shared memory objects
producer_idProducer ID (determines which ring to use)
Exceptions
std::runtime_errorif connection fails

Definition at line 333 of file mpsc_shm.cpp.

◆ operator=() [1/2]

MpscProducer & bb::ipc::MpscProducer::operator= ( const MpscProducer )
delete

◆ operator=() [2/2]

MpscProducer & bb::ipc::MpscProducer::operator= ( MpscProducer &&  other)
noexcept

Definition at line 296 of file mpsc_shm.cpp.

◆ publish()

void bb::ipc::MpscProducer::publish ( size_t  n)

Publish data to producer's ring (rings doorbell)

Parameters
nBytes to publish

Definition at line 369 of file mpsc_shm.cpp.

Member Data Documentation

◆ doorbell_

MpscDoorbell* bb::ipc::MpscProducer::doorbell_ = nullptr
private

Definition at line 151 of file mpsc_shm.hpp.

◆ doorbell_fd_

int bb::ipc::MpscProducer::doorbell_fd_ = -1
private

Definition at line 149 of file mpsc_shm.hpp.

◆ doorbell_len_

size_t bb::ipc::MpscProducer::doorbell_len_ = 0
private

Definition at line 150 of file mpsc_shm.hpp.

◆ producer_id_

size_t bb::ipc::MpscProducer::producer_id_ = 0
private

Definition at line 152 of file mpsc_shm.hpp.

◆ ring_

SpscShm bb::ipc::MpscProducer::ring_
private

Definition at line 148 of file mpsc_shm.hpp.


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