package shared-memory-ring

  1. Overview
  2. Docs

The front-end of the shared ring, which reads requests and reads responses from the remote domain.

type ('a, 'b) t

Type of a frontend. 'a is the response type, and 'b is the request id type (e.g. int or int64).

val init : sring:sring -> ('a, 'b) t

init ~sring is an initialized frontend attached to shared ring sring.

val slot : ('a, 'b) t -> int -> Cstruct.t

slot frontend idx retrieves the request/response slot at idx as an Cstruct.t. idx should be less than nr_ents.

val nr_ents : ('a, 'b) t -> int

nr_ents frontend is the number of slots in the underlying shared ring.

val get_free_requests : ('a, 'b) t -> int

get_free_requests frontend is the number of free request slots remaining in frontend.

val next_req_id : ('a, 'b) t -> int

next_req_id frontend advances the ring request producer and returns the latest slot id.

val ack_responses : ('a, 'b) t -> (Cstruct.t -> unit) -> unit

ack_response frontend f reads all the outstanding responses from the remote domain, calling f on them, and updating the response consumer pointer after each individual slot has been processed.

This is the low-level function which is only used if some sort of batching of requests is being performed, and normally you should use the flow-controlled poll that will ack the responses and wake up any sleeping threads that were waiting for that particular response.

val push_requests : ('a, 'b) t -> unit

push_requests frontend updates the shared request producer.

val push_requests_and_check_notify : ('a, 'b) t -> bool

push_requests_and_check_notify frontend updates the shared request producer, and returns true if an event notification is required to wake up the remote domain.

val to_string : ('a, 'b) t -> string

to_string t pretty-prints ring metadata