12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455open!CoreopenJs_of_ocaml(** Helpers for constructing types that can be sent between web workers via
{!With_transfer}. *)moduletypeS=sigtypettypemessagevalparse:message->tvalserialize:t->messageWith_transfer.Packed.tendmoduletypeFrom_worker=sigincludeSvalpost_message:t->unitendmoduletypeTo_worker=sigincludeStype'aresponsevalpost_message:t->worker:(message,'aresponse)Js_of_ocaml.Worker.workerJs_of_ocaml.Js.t->unitendmoduletypeTransferrable=sigmoduletypeS=SmoduletypeFrom_worker=From_workermoduletypeTo_worker=To_worker(** Convenience wrapper for
[Binable.to_bigstring m x |> Typed_array.Bigstring.to_arrayBuffer]. *)valto_arraybuf:'aBinable.m->'a->Typed_array.arrayBufferJs.t(** Convenience wrapper for
[Typed_array.Bigstring.of_arrayBuffer x |> Binable.of_bigstring m]. *)valof_arraybuf:'aBinable.m->Typed_array.arrayBufferJs.t->'a(** Construct a protocol where each message allocates a new bigstring and fills it via
[to_arraybuf], then transfers the buffer without further copies. The recipient
copies back to its heap with [of_arraybuf].
This is generally more performant than structured cloning, but not quite as nice as
using a type which can be transferred directly without serialization, such as
{!Immediate_iarray}. *)moduleOf_binable(T:sigtypet[@@derivingbin_io]end):Swithtypet:=T.tandtypemessage=Typed_array.arrayBufferJs.tend