Module Weak_hashtbl_async
Like Weak_hashtbl, but automatically collects keys with unused data, rather than requiring user code to call remove_keys_with_unused_data.
include module type of Weak_hashtbl
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> ('b -> Ppx_sexp_conv_lib.Sexp.t) -> ('a, 'b) t -> Ppx_sexp_conv_lib.Sexp.t
val create : ?growth_allowed:bool -> ?size:int -> (module Weak_hashtbl__.Import.Hashtbl.Key_plain with type t = 'a) -> ('a, 'b) tgrowth_allowedandsizeare both optionally passed on to the underlying call toHashtbl.create.
module Using_hashable = Weak_hashtbl.Using_hashableval mem : ('a, _) t -> 'a -> boolval find : ('a, 'b) t -> 'a -> 'b Weak_hashtbl__.Import.Heap_block.t optionval find_or_add : ('a, 'b) t -> 'a -> default:(unit -> 'b Weak_hashtbl__.Import.Heap_block.t) -> 'b Weak_hashtbl__.Import.Heap_block.tval remove : ('a, 'b) t -> 'a -> unitval add_exn : ('a, 'b) t -> key:'a -> data:'b Weak_hashtbl__.Import.Heap_block.t -> unitval replace : ('a, 'b) t -> key:'a -> data:'b Weak_hashtbl__.Import.Heap_block.t -> unitval key_is_using_space : ('a, _) t -> 'a -> boolkey_is_using_space t keyreturnstrueifkeyis using some space int.mem t keyimplieskey_is_using_space t key, but it is also possible that thatkey_is_using_space t key && not (mem t key).
val reclaim_space_for_keys_with_unused_data : (_, _) t -> unitreclaim_space_for_keys_with_unused_data treclaims space for all keys intwhose data has been detected (by a finalizer) to be unused. Onlykeys such thatkey_is_using_space t key && not (mem t key)will be reclaimed.
val set_run_when_unused_data : (_, _) t -> thread_safe_f:(unit -> unit) -> unitset_run_when_unused_data t ~thread_safe_fcallsthread_safe_fin the finalizer attached to eachdataint, after ensuring the entry being finalized will be handled in the next call toreclaim_space_for_keys_with_unused_data. This can be used to arrange to callreclaim_space_for_keys_with_unused_dataat a convenient time in the future.thread_safe_fmust be thread safe -- it is not safe for it to call anyWeak_hashtblfunctions.