package picos
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=544804c0bde4b29764f82f04e7defed7c06bc43e5a6ce3f7fdc326cb54a7f066
sha512=4c93427e477fb52374a554a8b9c4c92836a9b5899161275d1473269ab526a1f59177209140631ed763a55be375855dea12f076e18bf4124522414986c0e257be
doc/picos.stdio/Picos_stdio/Unix/index.html
Module Picos_stdio.Unix
Source
A transparently asynchronous replacement for a subset of the Unix
module that comes with OCaml.
In this module operations on file descriptors, such as read
and write
and others, including select
, implicitly block, in a scheduler friendly manner, to await for the file descriptor to become available for the operation. This works best with file descriptors set to non-blocking mode.
In addition to operations on file descriptors, in this module
also block in a scheduler friendly manner. Additionally
also block in a scheduler friendly manner except on Windows.
⚠️ Shared (i.e. inherited or inheritable or duplicated) file descriptors, such as stdin
, stdout
, and stderr
, typically should not be put into non-blocking mode, because that affects all of the parties using the shared file descriptors. However, for non-shared file descriptors non-blocking mode improves performance significantly with this module.
⚠️ Beware that this does not currently try to work around any limitations of the Unix
module that comes with OCaml. In particular, on Windows, only sockets can be put into non-blocking mode. Also, on Windows, scheduler friendly blocking only works properly with non-blocking file descriptors, i.e. sockets.
⚠️ This module uses Picos_select
and you may need to configure it at start of your application.
Please consult the documentation of the Unix
module that comes with OCaml.
Opaque type alias for Unix.file_descr
.
⚠️ Please consider the reference counting of file descriptors as an internal implementation detail and avoid depending on it.
close file_descr
marks the file descriptor as to be closed.
ℹ️ The file descriptor will either be closed immediately or after all concurrently running transparently asynchronous operations with the file descriptor have finished.
⚠️ After calling close
no new operations should be started with the file descriptor.
close_pair (fd1, fd2)
is equivalent to close fd1; close fd2
.
type error = Unix.error =
| E2BIG
| EACCES
| EAGAIN
| EBADF
| EBUSY
| ECHILD
| EDEADLK
| EDOM
| EEXIST
| EFAULT
| EFBIG
| EINTR
| EINVAL
| EIO
| EISDIR
| EMFILE
| EMLINK
| ENAMETOOLONG
| ENFILE
| ENODEV
| ENOENT
| ENOEXEC
| ENOLCK
| ENOMEM
| ENOSPC
| ENOSYS
| ENOTDIR
| ENOTEMPTY
| ENOTTY
| ENXIO
| EPERM
| EPIPE
| ERANGE
| EROFS
| ESPIPE
| ESRCH
| EXDEV
| EWOULDBLOCK
| EINPROGRESS
| EALREADY
| ENOTSOCK
| EDESTADDRREQ
| EMSGSIZE
| EPROTOTYPE
| ENOPROTOOPT
| EPROTONOSUPPORT
| ESOCKTNOSUPPORT
| EOPNOTSUPP
| EPFNOSUPPORT
| EAFNOSUPPORT
| EADDRINUSE
| EADDRNOTAVAIL
| ENETDOWN
| ENETUNREACH
| ENETRESET
| ECONNABORTED
| ECONNRESET
| ENOBUFS
| EISCONN
| ENOTCONN
| ESHUTDOWN
| ETOOMANYREFS
| ETIMEDOUT
| ECONNREFUSED
| EHOSTDOWN
| EHOSTUNREACH
| ELOOP
| EOVERFLOW
| EUNKNOWNERR of int
exception Unix_error of error * string * string
val error_message : error -> string
type open_flag = Unix.open_flag =
type stats = Unix.stats = {
st_dev : int;
st_ino : int;
st_kind : file_kind;
st_perm : file_perm;
st_nlink : int;
st_uid : int;
st_gid : int;
st_rdev : int;
st_size : int;
st_atime : float;
st_mtime : float;
st_ctime : float;
}
val stat : string -> stats
val lstat : string -> stats
val map_file :
file_descr ->
?pos:int64 ->
('a, 'b) Bigarray.kind ->
'c Bigarray.layout ->
bool ->
int array ->
('a, 'b, 'c) Bigarray.Genarray.t
val chmod : string -> file_perm -> unit
val access : string -> access_permission list -> unit
val mkdir : string -> file_perm -> unit
type dir_handle = Unix.dir_handle
val opendir : string -> dir_handle
val readdir : dir_handle -> string
val rewinddir : dir_handle -> unit
val closedir : dir_handle -> unit
val mkfifo : string -> file_perm -> unit
val create_process_env :
string ->
string array ->
string array ->
file_descr ->
file_descr ->
file_descr ->
int
val select :
file_descr list ->
file_descr list ->
file_descr list ->
float ->
file_descr list * file_descr list * file_descr list
select rds wrs exs timeout
is like Deps.Unix.select
, but uses Picos_select
to avoid blocking the thread.
🐌 You may find composing multi file descriptor awaits via other means with Picos_select
more flexible and efficient.
val sigprocmask : sigprocmask_command -> int list -> int list
type tm = Unix.tm = {
tm_sec : int;
tm_min : int;
tm_hour : int;
tm_mday : int;
tm_mon : int;
tm_year : int;
tm_wday : int;
tm_yday : int;
tm_isdst : bool;
}
val gmtime : float -> tm
val localtime : float -> tm
val times : unit -> process_times
val getitimer : interval_timer -> interval_timer_status
val setitimer :
interval_timer ->
interval_timer_status ->
interval_timer_status
type passwd_entry = Unix.passwd_entry = {
pw_name : string;
pw_passwd : string;
pw_uid : int;
pw_gid : int;
pw_gecos : string;
pw_dir : string;
pw_shell : string;
}
val getpwnam : string -> passwd_entry
val getgrnam : string -> group_entry
val getpwuid : int -> passwd_entry
val getgrgid : int -> group_entry
type inet_addr = Unix.inet_addr
val inet_addr_of_string : string -> inet_addr
val string_of_inet_addr : inet_addr -> string
val inet_addr_any : inet_addr
val inet_addr_loopback : inet_addr
val inet6_addr_any : inet_addr
val inet6_addr_loopback : inet_addr
val is_inet6_addr : inet_addr -> bool
val domain_of_sockaddr : sockaddr -> socket_domain
val socketpair :
?cloexec:bool ->
socket_domain ->
socket_type ->
int ->
file_descr * file_descr
type socket_bool_option = Unix.socket_bool_option =
type socket_int_option = Unix.socket_int_option =
type host_entry = Unix.host_entry = {
h_name : string;
h_aliases : string array;
h_addrtype : socket_domain;
h_addr_list : inet_addr array;
}
val gethostbyname : string -> host_entry
val gethostbyaddr : inet_addr -> host_entry
val getprotobyname : string -> protocol_entry
val getprotobynumber : int -> protocol_entry
val getservbyname : string -> string -> service_entry
val getservbyport : int -> string -> service_entry
type addr_info = Unix.addr_info = {
ai_family : socket_domain;
ai_socktype : socket_type;
ai_protocol : int;
ai_addr : sockaddr;
ai_canonname : string;
}
type getaddrinfo_option = Unix.getaddrinfo_option =
| AI_FAMILY of socket_domain
| AI_SOCKTYPE of socket_type
| AI_PROTOCOL of int
| AI_NUMERICHOST
| AI_CANONNAME
| AI_PASSIVE
val getaddrinfo : string -> string -> getaddrinfo_option list -> addr_info list
type getnameinfo_option = Unix.getnameinfo_option =
val getnameinfo : sockaddr -> getnameinfo_option list -> name_info
type terminal_io = Unix.terminal_io = {
mutable c_ignbrk : bool;
mutable c_brkint : bool;
mutable c_ignpar : bool;
mutable c_parmrk : bool;
mutable c_inpck : bool;
mutable c_istrip : bool;
mutable c_inlcr : bool;
mutable c_igncr : bool;
mutable c_icrnl : bool;
mutable c_ixon : bool;
mutable c_ixoff : bool;
mutable c_opost : bool;
mutable c_obaud : int;
mutable c_ibaud : int;
mutable c_csize : int;
mutable c_cstopb : int;
mutable c_cread : bool;
mutable c_parenb : bool;
mutable c_parodd : bool;
mutable c_hupcl : bool;
mutable c_clocal : bool;
mutable c_isig : bool;
mutable c_icanon : bool;
mutable c_noflsh : bool;
mutable c_echo : bool;
mutable c_echoe : bool;
mutable c_echok : bool;
mutable c_echonl : bool;
mutable c_vintr : char;
mutable c_vquit : char;
mutable c_verase : char;
mutable c_vkill : char;
mutable c_veof : char;
mutable c_veol : char;
mutable c_vmin : int;
mutable c_vtime : int;
mutable c_vstart : char;
mutable c_vstop : char;
}