IPC client for multi-client shared memory server.
More...
#include <mpsc_shm_client.hpp>
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.
◆ MpscShmClient() [1/3]
| bb::ipc::MpscShmClient::MpscShmClient |
( |
std::string |
base_name, |
|
|
size_t |
client_id |
|
) |
| |
|
inline |
◆ ~MpscShmClient()
| bb::ipc::MpscShmClient::~MpscShmClient |
( |
| ) |
|
|
overridedefault |
◆ MpscShmClient() [2/3]
◆ MpscShmClient() [3/3]
◆ close()
| void bb::ipc::MpscShmClient::close |
( |
| ) |
|
|
inlineoverridevirtual |
◆ connect()
| bool bb::ipc::MpscShmClient::connect |
( |
| ) |
|
|
inlineoverridevirtual |
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ 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_ns | Timeout 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_size | Size 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
-
| data | Pointer to message data |
| len | Length of message in bytes |
| timeout_ns | Timeout 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.
◆ base_name_
| std::string bb::ipc::MpscShmClient::base_name_ |
|
private |
◆ client_id_
| size_t bb::ipc::MpscShmClient::client_id_ |
|
private |
◆ producer_
◆ response_ring_
The documentation for this class was generated from the following file: