package octez-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-libs.lwt-result-stdlib/Tezos_lwt_result_stdlib/Lwtreslib/Traced/Hashtbl/Make_es/index.html
Module Hashtbl.Make_es
Parameters
module H : Hashtbl.HashedTypeSignature
include Bare_functor_outputs.Hashtbl.S_ES with type key = H.t
type key = H.tval create : int -> ('a, 'trace) tval clear : ('a, 'trace) t -> unitclear tbl cancels and removes all the promises in tbl.
val reset : ('a, 'trace) t -> unitreset tbl cancels and removes all the promises in tbl, and resizes tbl to its initial size.
val find_or_make :
('a, 'trace) t ->
key ->
(unit -> ('a, 'trace) result Lwt.t) ->
('a, 'trace) result Lwt.tfind_or_make tbl k make behaves differently depending on k being bound in tbl:
- if
kis bound intblthenfind_or_make tbl k makereturns the promisepthatkis bound to. Thispmight be already fulfilled withOk _or it might be pending. Thispcannot be already fulfilled withError _or already rejected. This is becauseError/rejected promises are removed from the table automatically. Note however that if thispis pending,pmight become fulfilled withError _or become rejected. - if
kis not bound intblthenmake ()is called and the returned promisepis bound tokintbl. Thenpis returned. Whenpis resolved, it may be removed automatically fromtblas described above.
remove tbl k cancels the promise bound to k in tbl and removes it. If k is not bound in tbl it does nothing.
val iter_with_waiting_es :
(key -> 'a -> (unit, 'trace) result Lwt.t) ->
('a, 'trace) t ->
(unit, 'trace) result Lwt.titer_with_waiting_es f tbl iterates f over the bindings in tbl.
Specifically, for each binding (k, p) it waits for p to be fulfilled with Ok v and calls f k v. If p fulfills with Error _ or is rejected, then no call to f is made for this binding. Note however that an Error/rejection in one promise returned by f interrupts the iteration.
It processes bindings one after the other: it waits for both the bound promise to resolve and then the call promise to resolve before continuing to the next binding.
val fold_with_waiting_es :
(key -> 'a -> 'b -> ('b, 'trace) result Lwt.t) ->
('a, 'trace) t ->
'b ->
('b, 'trace) result Lwt.tfold_with_waiting_es f tbl init folds init with f over the bindings in tbl.
Specifically, for each binding (k, p) it waits for p to be fulfilled with Ok v and determines the next accumulator by calling f k v acc. If p fulfills with Error _ or is rejected, then no call is made for this binding.
It processes bindings one after the other.
fold_promises f tbl init folds over the table, passing the raw promises to f. This means that f can observe Error/rejections.
This can be used to, e.g., count the number of resolved/unresolved promises.
fold_resolved f tbl init folds over the already resolved promises of tbl. More specifically, it folds over the v for all the promises fulfilled with Ok v that are bound in tbl.
val length : ('a, 'trace) t -> intval stats : ('a, 'trace) t -> Hashtbl.statisticsval iter_with_waiting_ep :
(key -> 'a -> (unit, 'error Trace.trace) result Lwt.t) ->
('a, 'error Trace.trace) t ->
(unit, 'error Trace.trace) result Lwt.t