Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
The (client) front-end connection to the shared ring.
Type of a frontend connection to a shared ring. 'a
is the response type, and 'b
is the request id type (e.g. int or int64).
val init : ('b -> string) -> ('a, 'b) Ring.Rpc.Front.t -> ('a, 'b) t
init string_of_id ring
initialises a stateful lwt client attached to ring
.
write ring req_fn
blocks until a ring slot is free, calls req_fn
on it and returns a thread that will wakeup when the response will be available.
val push : ('a, 'b) t -> (unit -> unit) -> unit
push ring notify_fn
advances ring
pointers, exposing the written requests to the other end. If the other end won't see the update, notify_fn
is called to signal it.
push_request_and_wait frontend notify_fn req_fn
is write
req_fn >>= fun t -> push notify_fn; return t
.
val push_request_async :
('a, 'b) t ->
(unit -> unit) ->
(Ring.buf -> 'b) ->
('a Lwt.t -> unit Lwt.t) ->
unit Lwt.t
push_request_async ring notify_fn req_fn free_fn
is like push_request_and_wait
except it calls free_fn
on the result of write
instead of returning it.
poll frontend resp_fn
polls the ring for responses, and wakes up any threads that are sleeping (as a result of calling push_request_and_wait
). This can be called regularly, or triggered via some external event such as an event channel signal.
val shutdown : ('a, 'b) t -> unit
wait_for_free frontend n
waits until at least n
slots are free. * It doesn't reserve them, so you'll probably need to use your own mutex * around this call. Requests are handled in order, so even large requests * will eventually be served.
val to_string : ('a, 'b) t -> string
to_string t
returns debug-printable description of the ring metadata