package picos_io
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0
doc/picos_io.fd/Picos_io_fd/index.html
Module Picos_io_fd
Source
Externally reference counted file descriptors.
If !report_leaks = true
then undisposed file descriptors will be reported at exit.
include Picos_aux_rc.S with type Resource.t = Unix.file_descr
Resource type.
Opaque type alias for the resource type.
create resource
adds an entry for the resource with an initial reference count of 1
to the table for the resource and returns the resource as a value of the opaque alias type.
The optional dispose
argument defaults to true
. When explicitly specified as ~dispose:false
, the resource will not be disposed when the reference count becomes zero. This is intended for special cases where a resource is e.g. managed outside of the control of the user program.
unsafe_get opaque_resource
casts the opaque alias type back to the resource type.
⚠️ This should only be called and the resource used either after creating the reference counting entry or after incrementing the reference count and before the matching decrement.
incr opaque_resource
tries to find the entry for the resource and increment the reference count.
decr opaque_resource
tries to find the entry for the resource and decrement the reference count. If the reference count becomes zero, the entry for the resource will be removed and the resource will be disposed, unless ~dispose:false
was specified for create
.
The optional close
argument defaults to false
. When explicitly specified as ~close:true
the resource will be marked as closed and attempts to increment the reference will fail.
type info = {
resource : Resource.t;
(*The resource.
*)count : int;
(*Reference count. This may be
*)0
.closed : bool;
dispose : bool;
bt : Printexc.raw_backtrace;
}
Information on a resource.