This crate implements a concurrent read-contention-free (RCF) fixed-capacity (FC) HashMap-based interner.
NB: Contention-free is not the same as lock-free.
All contention-free code is lock-free, but not vice versa.
Code can be lock-free yet not contention-free — for example, if it relies on
compare_exchangeoperations on atomics, or any other operations with a memory ordering stronger thanRelaxed.
- Stores key–value pairs, similar to an associative map.
For each unique key, insertion returns an interned handle — a unique, monotonically incrementedusizeID. - Contention-free for reading key–value pairs (as well as keys or values separately) by their assigned IDs.
- Fixed capacity — all memory is allocated upfront when the first key is inserted.
- Does not perform memory reclamation until the interner is dropped.
- Writes are not optimized — they incur overhead due to the internal
RwLock. - Re-insertion of an existing key is not supported.
- Deletion is not supported.
- The total number of key–value pairs is known in advance and strictly bounded from above.
- The total memory required to store all key–value pairs can be pre-allocated with sufficient margin.
- Interning operations are performed much less frequently than reads.