module Raw : sig ... end
val create : acquire:(unit ‑> ('a, 'e) Core.Result.t Async_kernel.Deferred.t) ‑> release:('a ‑> unit Async_kernel.Deferred.t) ‑> ('a, 'e) t
val with_ : ('a, 'e) t ‑> f:('a ‑> 'b Async_kernel.Deferred.t) ‑> ('b, 'e) Core.Result.t Async_kernel.Deferred.t
Access a resource without having to deal with Handle.t explicitly.
The resource is acquired before f
is called and released after f
returns a result
or raises an error to the enclosing monitor.
f
should not use 'a
after it raises or returns, whichever happens first.
Bind corresponds to resource dependency:
when acquiring x >>= f
, resource x
will be acquired, then f
is going to
be evaluated, then the result of f
is going to be acquired.
Releases will be done in the opposite order.
include Core.Monad.S2 with type (a, e) t := (a, e) t
include Base__.Monad_intf.Syntax2 with type (a, e) t := (a, e) t
module Let_syntax : sig ... end
module Monad_infix : Base__.Monad_intf.Infix2 with type (a, e) t := (a, e) t
val return : 'a ‑> ('a, _) t
val fail : 'e ‑> ('a, 'e) t
module Memo : functor (Key : Core.Hashable) -> sig ... end
val delayed_release : ('a, 'e) t ‑> delay:Core.Time.Span.t ‑> ('a, 'e) t
Delay all release
s by the given amount and don't wait for them