My working unpac repository
1(** A lock-free thread-safe [int]eger keyed hash table.
2
3 This is designed for associating thread specific state with threads within a
4 domain.
5
6 ⚠️ This is not {i parallelism-safe} — only {i thread-safe} within a single
7 domain. *)
8
9type 'v t
10(** A lock-free thread-safe [int]eger keyed hash table. *)
11
12val create : unit -> 'v t
13(** [create ()] returns a new lock-free thread-safe [int]eger keyed hash table.
14 The hash table is automatically resized. *)
15
16val length : 'v t -> int
17(** [length t] returns the number of {i bindings} in the hash table [t].
18
19 ⚠️ The returned value may be greater than the number of {i distinct keys} in
20 the hash table. *)
21
22val find : 'v t -> int -> 'v
23(** [find t k] returns the current binding of [k] in hash table [t], or raises
24 [Not_found] if no such binding exists.
25
26 ⚠️ This may use [raise_notrace] for performance reasons. *)
27
28val add : 'v t -> int -> 'v -> unit
29(** [add t k v] adds a binding of key [k] to value [v] to the hash table
30 shadowing the previous binding of the key [k], if any. *)
31
32val remove : 'v t -> int -> unit
33(** [remove t k] removes the most recent existing binding of key [k], if any,
34 from the hash table [t] thereby revealing the earlier binding of [k], if
35 any. *)