123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687(** [Io_uring_raw] is Async's wrapper over the Ocaml_uring API for using io_uring.
Each Io_uring_raw has an internal submission queue and a completion queue.
Whenever you make a syscall it is actually only added to the submission queue and
you receive a Handle that can be used to either get the Deferred of the underlying
syscall or cancel the syscall entirely (cancellation is only best effort, not a guarantee).
After some syscalls have been queued in the submission queue they can be sent to the
kernel in a batch via [submit] which will send all or part of the submission queue.
At this point the kernel will take care of the syscalls and whenever one is completed,
the corresponding event is added to the completion queue.
The completion queue can be consumed using [fill_completions] which will make the
syscalls deferred be filled up and makes room for new syscalls to be submitted.
There is no guarantee about the order in which syscalls are completed.
Extra care should be taken when using this module as certain usages might cause
starvation or even deadlocks. For instance, it could be the case that we fill up
the queue with very slow syscalls and are unable to quickly execute cheap syscalls
while waiting. Even worse, we might fill up the queue with blocking syscalls that
can only be executed after an additional syscall is made - which we cannot submit.
For further documenation on the internals of each syscall, read the analog documentation
in external/lib/ocaml_uring. *)open!CoreopenImportmoduletypeS=sigincludeIo_uring_types_intf.StypetmoduleSyscall_result:sigtypet=(int,Unix.Error.t)Result.t[@@derivingsexp_of]endmoduleHandle:sigtypetincludeInvariant.Swithtypet:=tendvalcreate:?polling_timeout:int->queue_depth:int->unit->tOr_error.tvalsupports_ext_arg:t->boolvalexit:t->unitvalregister_eventfd:t->File_descr.t->unitvalsubmit:t->intvalcqe_ready:t->timeout:float->boolvalfill_completions:t->intvalnoop:t->Handle.tvalread:t->file_offset:Int63.t->File_descr.t->Cstruct.t->Handle.tvalwrite:t->file_offset:Int63.t->File_descr.t->Cstruct.t->Handle.tvalreadv:t->file_offset:Int63.t->File_descr.t->Cstruct.tlist->Handle.tvalwritev:t->file_offset:Int63.t->File_descr.t->Cstruct.tlist->Handle.tvalpoll_add:t->File_descr.t->Poll_mask.t->Handle.t(** Openat2 will fail if non-zero perms are passed while no file is being created
(i.e. when creat or tmpfile are not passed as flags) *)valopenat2:t->access:[`R|`W|`RW]->flags:Open_flags.t->perm:Unix.file_perm->resolve:Resolve.t->?fd:File_descr.t->string->Handle.tvalclose:t->File_descr.t->Handle.tvallink:t->follow:bool->target:string->link_name:string->Handle.tvalunlink:t->dir:bool->?fd:File_descr.t->string->Handle.tvaltimeout:t->?absolute:bool->Clock.t->int64->Handle.tvalstatx:t->?fd:File_descr.t->mask:Statx.Mask.t->string->Statx.t->Statx.Flags.t->Handle.tvalcancel:t->Handle.t->unitDeferred.tvalsyscall_result:Handle.t->Syscall_result.tDeferred.tend