Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ipc_client.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <memory>
6#include <span>
7#include <string>
8#include <sys/types.h>
9
10namespace bb::ipc {
11
18class IpcClient {
19 public:
20 IpcClient() = default;
21 virtual ~IpcClient() = default;
22
23 // Abstract interface - no copy or move
24 IpcClient(const IpcClient&) = delete;
25 IpcClient& operator=(const IpcClient&) = delete;
26 IpcClient(IpcClient&&) = delete;
28
33 virtual bool connect() = 0;
34
42 virtual bool send(const void* data, size_t len, uint64_t timeout_ns) = 0;
43
55 virtual std::span<const uint8_t> receive(uint64_t timeout_ns) = 0;
56
65 virtual void release(size_t message_size) = 0;
66
70 virtual void close() = 0;
71
72 // Factory methods
73 static std::unique_ptr<IpcClient> create_socket(const std::string& socket_path);
74 static std::unique_ptr<IpcClient> create_shm(const std::string& base_name);
75};
76
77} // namespace bb::ipc
Abstract interface for IPC client.
virtual bool send(const void *data, size_t len, uint64_t timeout_ns)=0
Send a message to the server.
virtual bool connect()=0
Connect to the server.
virtual void close()=0
Close the connection.
IpcClient & operator=(IpcClient &&)=delete
IpcClient(const IpcClient &)=delete
virtual std::span< const uint8_t > receive(uint64_t timeout_ns)=0
Receive a message from the server (zero-copy for shared memory)
virtual ~IpcClient()=default
virtual void release(size_t message_size)=0
Release the previously received message.
IpcClient(IpcClient &&)=delete
static std::unique_ptr< IpcClient > create_socket(const std::string &socket_path)
IpcClient & operator=(const IpcClient &)=delete
static std::unique_ptr< IpcClient > create_shm(const std::string &base_name)
const std::vector< MemoryValue > data
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
uint8_t len