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

IPC client for multi-client shared memory server. More...

#include <mpsc_shm_client.hpp>

Inheritance diagram for bb::ipc::MpscShmClient:
bb::ipc::IpcClient

Public Member Functions

 MpscShmClient (std::string base_name, size_t client_id)
 
 ~MpscShmClient () override=default
 
 MpscShmClient (const MpscShmClient &)=delete
 
MpscShmClientoperator= (const MpscShmClient &)=delete
 
 MpscShmClient (MpscShmClient &&)=delete
 
MpscShmClientoperator= (MpscShmClient &&)=delete
 
bool connect () override
 Connect to the server.
 
bool send (const void *data, size_t len, uint64_t timeout_ns) override
 Send a message to the server.
 
std::span< const uint8_t > receive (uint64_t timeout_ns) override
 Receive a message from the server (zero-copy for shared memory)
 
void release (size_t message_size) override
 Release the previously received message.
 
void close () override
 Close the connection.
 
- Public Member Functions inherited from bb::ipc::IpcClient
 IpcClient ()=default
 
virtual ~IpcClient ()=default
 
 IpcClient (const IpcClient &)=delete
 
IpcClientoperator= (const IpcClient &)=delete
 
 IpcClient (IpcClient &&)=delete
 
IpcClientoperator= (IpcClient &&)=delete
 

Private Attributes

std::string base_name_
 
size_t client_id_
 
std::optional< MpscProducerproducer_
 
std::optional< SpscShmresponse_ring_
 

Additional Inherited Members

- Static Public Member Functions inherited from bb::ipc::IpcClient
static std::unique_ptr< IpcClientcreate_socket (const std::string &socket_path)
 
static std::unique_ptr< IpcClientcreate_shm (const std::string &base_name)
 
static std::unique_ptr< IpcClientcreate_mpsc_shm (const std::string &base_name, size_t client_id)
 

Detailed Description

IPC client for multi-client shared memory server.

Uses MpscProducer for sending requests and a dedicated SPSC ring for receiving responses. Each client is assigned a unique client_id.

Definition at line 22 of file mpsc_shm_client.hpp.

Constructor & Destructor Documentation

◆ MpscShmClient() [1/3]

bb::ipc::MpscShmClient::MpscShmClient ( std::string  base_name,
size_t  client_id 
)
inline

Definition at line 24 of file mpsc_shm_client.hpp.

◆ ~MpscShmClient()

bb::ipc::MpscShmClient::~MpscShmClient ( )
overridedefault

◆ MpscShmClient() [2/3]

bb::ipc::MpscShmClient::MpscShmClient ( const MpscShmClient )
delete

◆ MpscShmClient() [3/3]

bb::ipc::MpscShmClient::MpscShmClient ( MpscShmClient &&  )
delete

Member Function Documentation

◆ close()

void bb::ipc::MpscShmClient::close ( )
inlineoverridevirtual

Close the connection.

Implements bb::ipc::IpcClient.

Definition at line 98 of file mpsc_shm_client.hpp.

◆ connect()

bool bb::ipc::MpscShmClient::connect ( )
inlineoverridevirtual

Connect to the server.

Returns
true if connection successful, false otherwise

Implements bb::ipc::IpcClient.

Definition at line 37 of file mpsc_shm_client.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

MpscShmClient & bb::ipc::MpscShmClient::operator= ( MpscShmClient &&  )
delete

◆ receive()

std::span< const uint8_t > bb::ipc::MpscShmClient::receive ( uint64_t  timeout_ns)
inlineoverridevirtual

Receive a message from the server (zero-copy for shared memory)

Parameters
timeout_nsTimeout in nanoseconds
Returns
Span of message data (empty on error/timeout)

The span remains valid until release() is called or the next recv(). For shared memory: direct view into ring buffer (true zero-copy) For sockets: view into internal buffer (eliminates one copy)

Must be followed by release() to consume the message.

Implements bb::ipc::IpcClient.

Definition at line 82 of file mpsc_shm_client.hpp.

◆ release()

void bb::ipc::MpscShmClient::release ( size_t  message_size)
inlineoverridevirtual

Release the previously received message.

Parameters
message_sizeSize of the message being released (from span.size())

Must be called after recv() to consume the message and free resources. For shared memory: releases space in the ring buffer For sockets: no-op (message already consumed during recv)

Implements bb::ipc::IpcClient.

Definition at line 90 of file mpsc_shm_client.hpp.

◆ send()

bool bb::ipc::MpscShmClient::send ( const void *  data,
size_t  len,
uint64_t  timeout_ns 
)
inlineoverridevirtual

Send a message to the server.

Parameters
dataPointer to message data
lenLength of message in bytes
timeout_nsTimeout in nanoseconds (0 = infinite)
Returns
true if sent successfully, false on error or timeout

Implements bb::ipc::IpcClient.

Definition at line 59 of file mpsc_shm_client.hpp.

Member Data Documentation

◆ base_name_

std::string bb::ipc::MpscShmClient::base_name_
private

Definition at line 105 of file mpsc_shm_client.hpp.

◆ client_id_

size_t bb::ipc::MpscShmClient::client_id_
private

Definition at line 106 of file mpsc_shm_client.hpp.

◆ producer_

std::optional<MpscProducer> bb::ipc::MpscShmClient::producer_
private

Definition at line 107 of file mpsc_shm_client.hpp.

◆ response_ring_

std::optional<SpscShm> bb::ipc::MpscShmClient::response_ring_
private

Definition at line 108 of file mpsc_shm_client.hpp.


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