package uwt
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e653a9fc7a13c5435a58780ddf02ff15c8ff92f63f6ff4406b1d312e3060807
md5=549517d3e9bcf5533097e4c83f891e2c
doc/uwt.async/Uwt/index.html
Module Uwt
Uwt main module
Basic overview:
- naming conventions mirror the conventions of libuv, so you can easily consult the official
libuv manual. Selected parts of the manual are now included inside the mli files (credits toAuthors), the libuv manual is however more up-to-date.
- Requests are translated to lwt-threads, therefore
uv_req_tis kept internal.
- Callbacks that are called continually are most of the time not translated to the usual lwt semantic.
- Uwt is not compatible with
lwt.unix. It's not a furtherLwt_enginein addition toselectandlibev.
- Uwt is not thread safe. All uwt functions should be called from your main thread.
Please notice, that there are subtle differences compared to lwt.unix. Because all requests are accomplished by libuv (sometimes in parallel in different threads), you don't have that kind of low level control, that you have with lwt.unix. Also Lwt.cancel behaves differently and you won't notice it by looking at the type information.
Stream.writeand related functions can never be canceled. The analogous write functions inLwt_unixhowever are cancelable as long as the underlying file descriptor is not opened in blocking mode. (Stream.readcurrently returns the only cancelable thread insideStreamand its subclasses. But there is no guarantee thatTcp.readwill continue to be cancelable under Windows in future libuv versions.)
- Everything that is done in work threads (e.g. File I/O, DNS resolution, etc.) is cancelable, as long as the task is just queued for execution and not already running in a parallel thread. However, it's never possible to cancel a background task in
Lwt_unix.
include module type of Uwt_base
with type error = Uwt_base.error
with type 'a uv_result = 'a Uwt_base.uv_result
with type file = Uwt_base.file
with type sockaddr = Uwt_base.sockaddr
with type 'a Int_result.t = 'a Uwt_base.Int_result.t
with type Fs_types.uv_open_flag = Uwt_base.Fs_types.uv_open_flag
with type Fs_types.file_kind = Uwt_base.Fs_types.file_kind
with type Fs_types.symlink_mode = Uwt_base.Fs_types.symlink_mode
with type Fs_types.access_permission = Uwt_base.Fs_types.access_permission
with type Fs_types.stats = Uwt_base.Fs_types.stats
with type Misc.timeval = Uwt_base.Misc.timeval
with type Misc.rusage = Uwt_base.Misc.rusage
with type Misc.cpu_times = Uwt_base.Misc.cpu_times
with type Misc.cpu_info = Uwt_base.Misc.cpu_info
with type Misc.interface_address = Uwt_base.Misc.interface_address
with type Misc.handle_type = Uwt_base.Misc.handle_type
with type Misc.version = Uwt_base.Misc.version
with type Iovec_write.t = Uwt_base.Iovec_write.t
Uwt_base contains type definitions and functions that are shared by Uwt and Uv_fs_sync
type error = Uwt_base.error = | E2BIG(*argument list too long
*)| EACCES(*permission denied
*)| EADDRINUSE(*address already in use
*)| EADDRNOTAVAIL(*address not available
*)| EAFNOSUPPORT(*address family not supported
*)| EAGAIN(*resource temporarily unavailable
*)| EAI_ADDRFAMILY(*address family not supported
*)| EAI_AGAIN(*temporary failure
*)| EAI_BADFLAGS(*bad ai_flags value
*)| EAI_BADHINTS(*invalid value for hints
*)| EAI_CANCELED(*request canceled
*)| EAI_FAIL(*permanent failure
*)| EAI_FAMILY(*ai_family not supported
*)| EAI_MEMORY(*out of memory
*)| EAI_NODATA(*no address
*)| EAI_NONAME(*unknown node or service
*)| EAI_OVERFLOW(*argument buffer overflow
*)| EAI_PROTOCOL(*resolved protocol is unknown
*)| EAI_SERVICE(*service not available for socket type
*)| EAI_SOCKTYPE(*socket type not supported
*)| EALREADY(*connection already in progress
*)| EBADF(*bad file descriptor
*)| EBUSY(*resource busy or locked
*)| ECANCELED(*operation canceled
*)| ECHARSET(*Windows filenames (and similar parameters) are expected to be utf-8 encoded.
*)ECHARSETis returned, if one parameter contains invalid byte sequences. Furthermore,ECHARSETwill be returned, if your strings contain null bytes (on *nix, too).| ECONNABORTED(*software caused connection abort
*)| ECONNREFUSED(*connection refused
*)| ECONNRESET(*connection reset by peer
*)| EDESTADDRREQ(*destination address required
*)| EEXIST(*file already exists
*)| EFAULT(*bad address in system call argument
*)| EFBIG(*file too large
*)| EHOSTUNREACH(*host is unreachable
*)| EINTR(*interrupted system call
*)| EINVAL(*invalid argument
*)| EIO(*i/o error
*)| EISCONN(*socket is already connected
*)| EISDIR(*illegal operation on a directory
*)| ELOOP(*too many symbolic links encountered
*)| EMFILE(*too many open files
*)| EMSGSIZE(*message too long
*)| ENAMETOOLONG(*name too long
*)| ENETDOWN(*network is down
*)| ENETUNREACH(*network is unreachable
*)| ENFILE(*file table overflow
*)| ENOBUFS(*no buffer space available
*)| ENODEV(*no such device
*)| ENOENT(*no such file or directory
*)| ENOMEM(*not enough memory
*)| ENONET(*machine is not on the network
*)| ENOPROTOOPT(*protocol not available
*)| ENOSPC(*no space left on device
*)| ENOSYS(*function not implemented
*)| ENOTCONN(*socket is not connected
*)| ENOTDIR(*not a directory
*)| ENOTEMPTY(*directory not empty
*)| ENOTSOCK(*socket operation on non-socket
*)| ENOTSUP(*operation not supported on socket
*)| EPERM(*operation not permitted
*)| EPIPE(*broken pipe
*)| EPROTO(*protocol error
*)| EPROTONOSUPPORT(*protocol not supported
*)| EPROTOTYPE(*protocol wrong type for socket
*)| ERANGE(*result too large
*)| EROFS(*read-only file system
*)| ESHUTDOWN(*cannot send after transport endpoint shutdown
*)| ESPIPE(*invalid seek
*)| ESRCH(*no such process
*)| ETIMEDOUT(*connection timed out
*)| ETXTBSY(*text file is busy
*)| EXDEV(*cross-device link not permitted
*)| UNKNOWN(*unknown error
*)| EOF(*end of file
*)| ENXIO(*no such device or address
*)| EMLINK(*too many links
*)| EHOSTDOWN(*host is down
*)| EREMOTEIO(*remote I/O error
*)| ENOTTY(*inappropriate ioctl for device
*)| EFTYPE(*inappropriate file type or format
*)| UWT_EFATAL(*something happened that the author of uwt didn't expect. Probably a bug or the api of libuv has changed in the meanwhile
*)
val strerror : error -> stringerror message for the given error code
val err_name : error -> stringerror name for the given error code
val to_unix_error : error -> Unix.errormap error to Unix.error , Unix.EUNKNOWNERR is used, if the mapping is not possible
val of_unix_error : Unix.error -> errorget back the original Uwt.error from an exception raised by a Uwt function
type 'a uv_result = 'a Uwt_base.uv_resultmodule Int_result : sig ... endInt_result.t is used instead of 'a result, if a function returns either an error or a non-negative integer (including unit/bool).
type file = Uwt_base.fileAbstract type for a file descriptor. Unlike Unix.file_descr it is not intended to wrap a SOCKET.
type sockaddr = Uwt_base.sockaddrtype buf =
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.tval stdin : fileFile descriptor for standard input.
val stdout : fileFile descriptor for standard output.
val stderr : fileFile descriptor for standard error.
module Iovec_write : sig ... endpass multiple buffers at once to a libuv write function.
module Fs_types : sig ... endmodule type Fs_functions = sig ... endmodule Conv : sig ... endmodule Misc : sig ... endThis section contains miscellaneous functions that don't really belong in any other section.
module Sys_info : sig ... endInformation about your operating system.
module Main : sig ... endAnalogue of Lwt_main
module Fs : sig ... endmodule Handle_ext : sig ... endmodule Handle_fileno : sig ... endThe usage of fileno is unsafe and strongly discouraged. But it's sometimes necessary, if you need to interact with third parties libraries. Rules:
module Stream : sig ... endStream handles provide an abstraction of a duplex communication channel. Stream.t is an abstract type, libuv provides 3 stream implementations in the form of Tcp.t, Pipe.t and Tty.t.
module Tcp : sig ... endTCP handles are used to represent both TCP streams and servers.
module Udp : sig ... endUDP handles encapsulate UDP communication for both clients and servers.
module Tty : sig ... endTTY handles represent a stream for the console.
module Pipe : sig ... endPipe handles provide an abstraction over local domain sockets on Unix and named pipes on Windows.
module Timer : sig ... endTimer handles are used to schedule callbacks to be called in the future.
module Signal : sig ... endSignal handles implement Unix style signal handling on a per-event loop bases.
module Poll : sig ... endPoll handles are used to watch file descriptors for readability, writability and disconnection similar to the purpose of poll(2).
module Fs_event : sig ... endFS Event handles allow the user to monitor a given path for changes, for example, if the file was renamed or there was a generic change in it. This handle uses the best backend for the job on each platform.
module Fs_poll : sig ... endFS Poll handles allow the user to monitor a given path for changes. Unlike Fs_event.t, fs poll handles use stat to detect when a file has changed so they can work on file systems where fs event handles can't.
module Process : sig ... endProcess handles will spawn a new process and allow the user to control it and establish communication channels with it using streams.
module Dns : sig ... endlibuv provides asynchronous variants of getaddrinfo and getnameinfo.
module Unix : sig ... endPopular functions from the standard Unix module, but all calls are executed in work threads.
module C_worker : sig ... endmodule Async : sig ... endAsync handles allow the user to "wakeup" the event loop and get a callback called from another (system) thread.
module Debug : sig ... endCommon helper for ad hoc debugging. Don't use them inside production code.