Skip to main content

Module refcount

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