Module refcount

Source
Expand description

Helpers for reference counting

Two main purposes:

  • Consistent handling of overflow and underflow
  • Assurance of incrementing/decrementing as appropriate, including in combination with a slotmap containing the referenced data.

The caller is responsible for making sure that the right instance’s Count is passed to the methods on Ref.

Macros§

slotmap_dec_ref 🔒
Decrement a refcount and maybe remove a corresponding slotmap entry

Structs§

Count 🔒
A reference count, counting references with id type K
Garbage 🔒
Something which has become garbage
Overflow 🔒
Error: refcount overflowed
Ref 🔒
An copy of a slotmap_careful::Key K, which is counted by a RefCount

Functions§

dec_raw 🔒
Decrement this refcount, but don’t care about any Refs
inc_raw 🔒
Increment this refcount, but don’t care about any Refs
slotmap_insert 🔒
Insert a new entry into a slotmap using refcounted keys
slotmap_remove_early 🔒
Unconditionally remove en entry from the slotmap, given a strong ref
slotmap_try_insert 🔒
Insert a new entry into a slotmap using refcounted keys, fallibly and with extra data

Type Aliases§

RawCount 🔒
Local alias for the counter type