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

Classes

class  IpcClient
 Abstract interface for IPC client. More...
 
class  IpcServer
 Abstract interface for IPC server. More...
 
class  MpscConsumer
 Multi-producer single-consumer - consumer side. More...
 
struct  MpscDoorbell
 Shared doorbell for waking consumer. More...
 
class  MpscProducer
 Multi-producer single-consumer - producer side. More...
 
class  ShmClient
 IPC client implementation using shared memory. More...
 
class  ShmServer
 IPC server implementation using shared memory. More...
 
class  ShutdownRequested
 Exception thrown by handler to signal graceful shutdown. More...
 
class  SocketClient
 IPC client implementation using Unix domain sockets. More...
 
class  SocketServer
 IPC server implementation using Unix domain sockets. More...
 
struct  SpscCtrl
 Control structure for SPSC ring buffer. More...
 
class  SpscShm
 Lock-free single-producer single-consumer shared memory ring buffer. More...
 

Functions

int futex_wait (volatile uint32_t *addr, uint32_t expect)
 Atomic compare-and-wait operation.
 
int futex_wait_timeout (volatile uint32_t *addr, uint32_t expect, uint64_t timeout_ns)
 Atomic compare-and-wait operation with timeout.
 
int futex_wake (volatile uint32_t *addr, int n)
 Wake waiters blocked on an address.
 
uint64_t mono_ns_now ()
 Get current monotonic time in nanoseconds.
 
bool ring_send_msg (SpscShm &ring, const void *data, size_t len, uint64_t timeout_ns)
 
std::span< const uint8_t > ring_receive_msg (SpscShm &ring, uint64_t timeout_ns)
 

Variables

constexpr size_t SPSC_CACHELINE = 64
 

Function Documentation

◆ futex_wait()

int bb::ipc::futex_wait ( volatile uint32_t *  addr,
uint32_t  expect 
)
inline

Atomic compare-and-wait operation.

Blocks if the value at addr equals expect. Works across process boundaries.

Parameters
addrPointer to 32-bit value to wait on
expectExpected value - blocks if *addr == expect
Returns
0 on wake, -1 on error

Definition at line 45 of file futex.hpp.

◆ futex_wait_timeout()

int bb::ipc::futex_wait_timeout ( volatile uint32_t *  addr,
uint32_t  expect,
uint64_t  timeout_ns 
)
inline

Atomic compare-and-wait operation with timeout.

Blocks if the value at addr equals expect, but only for up to timeout_ns nanoseconds. Works across process boundaries.

Parameters
addrPointer to 32-bit value to wait on
expectExpected value - blocks if *addr == expect
timeout_nsMaximum time to wait in nanoseconds (0 = return immediately if value matches)
Returns
0 on wake, -1 on error (check errno for ETIMEDOUT on timeout)

Definition at line 69 of file futex.hpp.

◆ futex_wake()

int bb::ipc::futex_wake ( volatile uint32_t *  addr,
int  n 
)
inline

Wake waiters blocked on an address.

Wakes up to n waiters blocked on addr. Works across process boundaries.

Parameters
addrPointer to 32-bit value to wake on
nNumber of waiters to wake (1 for single, INT_MAX for all)
Returns
Number of waiters woken, or -1 on error

Definition at line 98 of file futex.hpp.

◆ mono_ns_now()

uint64_t bb::ipc::mono_ns_now ( )
inline

Get current monotonic time in nanoseconds.

Uses CLOCK_MONOTONIC which is suitable for measuring elapsed time and not affected by system clock adjustments.

Returns
Current monotonic time in nanoseconds, or 0 on error

Definition at line 31 of file utilities.hpp.

◆ ring_receive_msg()

std::span< const uint8_t > bb::ipc::ring_receive_msg ( SpscShm ring,
uint64_t  timeout_ns 
)
inline

Definition at line 39 of file shm_common.hpp.

◆ ring_send_msg()

bool bb::ipc::ring_send_msg ( SpscShm ring,
const void *  data,
size_t  len,
uint64_t  timeout_ns 
)
inline

Definition at line 12 of file shm_common.hpp.

Variable Documentation

◆ SPSC_CACHELINE

constexpr size_t bb::ipc::SPSC_CACHELINE = 64
constexpr

Definition at line 21 of file spsc_shm.hpp.