Riddance provides the [Registry] container, which stores objects and issues unique IDs for
them, also known as a "slot map" or an "arena". Features include:
- New IDs can be "reserved" atomically, without locking the [
Registry]. Seereserve_idandreserve_ids. - When the generation of a slot reaches its maximum, the slot is "retired" instead of allowing the generation to roll over to zero. This prevents logic errors from colliding IDs.
- The default [
Id] type is 64 bits, but callers that need smallers IDs can useId32, which has a configurable number of generation bits. - The
recyclemethod makes it possible to reuse previously retired slots, though it can introduce logic errors if you violate its contract. It's mainly intended for callers who useId32. - By default ID types incorporate the
Ttype parameter of theRegistrythat created them, to avoid confusing IDs from different registries.
Example
#