Files
catscript/include/cat
Minus 22b8de3040 value: thread-safe reference counting foundation
Add an atomic reference count to the common value header and the
retain/release API, without changing any existing ownership behaviour
(containers still do not free their children, so nothing new is freed
and the suite stays green).

- CAT_VALUE_Value gains `_Atomic long refcnt`.
- cat_value_retain / cat_value_release use atomic RMW with acq_rel
  ordering; the last release calls vtable->destroy after an acquire
  fence.  cat_value_refcount and cat_value_make_immortal complete the
  API.
- every heap constructor sets refcnt = 1 (its creator's reference).
- singletons are immortal (refcnt = -1): the empty object and
  true/false, so they are never freed and need no locking.

This makes the COUNT safe to share across threads.  It does not make a
mutable object safe under concurrent writes.
2026-11-17 22:12:31 +00:00
..