Page
Library
Module
Module type
Parameter
Class
Class type
Source
Affect_unix.UnixSourceUnix module overriden with cooperative functions and actions.
Unix module so that there are few surprises when one is swapped for the other.Warning. Most of the functionality of this module relies on an Unix.unblocker being setup on the executing domain.
The full Unix module from the OCaml unix library is included here. It is hidden from the docs due to a suboptimal reading experience.
include module type of Unix
with type file_descr = Unix.file_descr
and …close_noerr is like Unix.close but never raises.
val socket :
?cloexec:bool ->
Unix.socket_domain ->
Unix.socket_type ->
int ->
Unix.file_descrsocket is like Unix.socket except it has cloexec set to true by default and it sets the socket to non-blocking mode with Unix.set_nonblock.
accept is a cooperative Unix.accept.
connect is a cooperative Unix.connect.
read is a cooperative Unix.read.
val read_bigarray :
Unix.file_descr ->
(_, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
int ->
int ->
intread_bigarray is a cooperative Unix.read_bigarray.
write is a cooperative Unix.write.
val write_bigarray :
Unix.file_descr ->
(_, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
int ->
int ->
intwrite_bigarray is a cooperative Unix.write_bigarray.
write_substring is a cooperative Unix.write_substring.
single_write is a cooperative Unix.single_write.
val single_write_bigarray :
Unix.file_descr ->
(_, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t ->
int ->
int ->
intsingle_write_bigarray is a cooperative Unix.single_write_bigarray.
single_write_substring is a cooperative Unix.single_write_substring.
wait_readable fd tag is the action used by the read operations and accept. The action invocation is enabled and synchronizes with tag whenever the non-blocking file descriptor fd becomes available for reading.
wait_writable fd tag is the action used by the write operations and connect. The action invocation is enabled and synchronizes with tag whenever the non-blocking file descriptor fd becomes available for writing.
unblocker () is an action unblocker to use with Affect.Fun.Async.main for handling actions from Unix, Mtime and Ptime.
val main :
?sigpipe:Signal.handler ->
?domain_spawn:((unit -> unit) -> unit Domain.t) ->
?domain_count:int ->
?schedule:Affect.Fun.Async.Schedule.t ->
?handler:Affect.Fun.Async.Call_handler.t ->
(unit -> 'a) ->
'aInvoking main expands to:
Unix.Signal.set_and_restore Sys.sigpipe sigpipe @@ fun () ->
let unblocker = Unix.unblocker () in
Fun.Async.main ~unblocker ?domain_spawn ?domain_count ?schedule ?handler fThe default of sigpipe is Unix.Signal.handler.Ignore which is the right default.
Unix moduleaccept, assume a non-blocking file descriptor, handles EWOULDBLOCK and EGAIN by invoking wait_readable.connect, assumes a non-blocking file descriptor, handle EINPROGRESS by invoking wait_readable and after that checks if an error occcured with Unix.getsockopt_errorsocket, after the socket is created it is directly set to non-blocking mode with a call to Unix.set_nonblock.read, read_bigarray, write, write_bigarray, write_substring, single_write, single_write_bigarray, single_write_substring assume a non-blocking file descriptor and handles EWOULDBLOCK and EAGAIN by invoking wait_readable or wait_writable.Signal module is added.