Module Async_extended.Run_in_fork

val run_in_fork : ?⁠max_len:int ‑> bin_t:'b Bin_prot.Type_class.t ‑> f:(unit ‑> 'b) ‑> unit ‑> 'b Core.Or_error.t Async.Deferred.t

run_in_fork forks and then runs f in the child process, and then writes the result back to the parent process over a unix pipe. Note that f cannot contain any async calculations. An Error will be returned if an exception is thrown in the child, or the child disconnects before writing the result.

type 'a ret =
| Part of 'a
| Err of Core.Error.t
| Done
val run_in_fork_multiple : ?⁠max_len:int ‑> bin_t:'b Bin_prot.Type_class.t ‑> f:(write:('b ‑> unit) ‑> unit) ‑> unit ‑> 'b ret Async.Pipe.Reader.t

run_in_fork_multiple is just like run_in_fork but allows the user to write multiple results from the child to the parent. This is useful when the the data being written over the pipe is very large, as deserializing the data may take a long time, and the user may want to split the data into smaller chunks.