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

IPC client implementation using shared memory. More...

#include <shm_client.hpp>

Inheritance diagram for bb::ipc::ShmClient:
bb::ipc::IpcClient

Public Member Functions

 ShmClient (std::string base_name)
 
 ~ShmClient () override=default
 
 ShmClient (const ShmClient &)=delete
 
ShmClientoperator= (const ShmClient &)=delete
 
 ShmClient (ShmClient &&)=delete
 
ShmClientoperator= (ShmClient &&)=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.
 
void debug_dump () const
 
- 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_
 
std::optional< SpscShmrequest_ring_
 
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)
 

Detailed Description

IPC client implementation using shared memory.

Uses SPSC (single-producer single-consumer) for both requests and responses. Simple 1:1 client-server communication.

Definition at line 25 of file shm_client.hpp.

Constructor & Destructor Documentation

◆ ShmClient() [1/3]

bb::ipc::ShmClient::ShmClient ( std::string  base_name)
inlineexplicit

Definition at line 27 of file shm_client.hpp.

◆ ~ShmClient()

bb::ipc::ShmClient::~ShmClient ( )
overridedefault

◆ ShmClient() [2/3]

bb::ipc::ShmClient::ShmClient ( const ShmClient )
delete

◆ ShmClient() [3/3]

bb::ipc::ShmClient::ShmClient ( ShmClient &&  )
delete

Member Function Documentation

◆ close()

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

Close the connection.

Implements bb::ipc::IpcClient.

Definition at line 86 of file shm_client.hpp.

◆ connect()

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

Connect to the server.

Returns
true if connection successful, false otherwise

Implements bb::ipc::IpcClient.

Definition at line 39 of file shm_client.hpp.

◆ debug_dump()

void bb::ipc::ShmClient::debug_dump ( ) const
inline

Definition at line 92 of file shm_client.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ receive()

std::span< const uint8_t > bb::ipc::ShmClient::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 70 of file shm_client.hpp.

◆ release()

void bb::ipc::ShmClient::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 78 of file shm_client.hpp.

◆ send()

bool bb::ipc::ShmClient::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 62 of file shm_client.hpp.

Member Data Documentation

◆ base_name_

std::string bb::ipc::ShmClient::base_name_
private

Definition at line 103 of file shm_client.hpp.

◆ request_ring_

std::optional<SpscShm> bb::ipc::ShmClient::request_ring_
private

Definition at line 104 of file shm_client.hpp.

◆ response_ring_

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

Definition at line 105 of file shm_client.hpp.


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