mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Add a new reference-counted shared pointer type, `bun.ptr.Shared`. Features: * Can hold data of any type; doesn't require adding a `ref_count` field * Reference count is an internal implementation detail; will never get out of sync due to erroneous manipulation * Supports weak pointers * Supports optional pointers with no overhead (`Shared(?*T)` is the same size as `Shared(*T)`) * Has an atomic thread-safe version: `bun.ptr.AtomicShared` * Defaults to `bun.default_allocator`, but can handle other allocators as well, with both static and dynamic polymorphism The following types are now deprecated and will eventually be removed: * `bun.ptr.RefCount` * `bun.ptr.ThreadSafeRefCount` * `bun.ptr.RefPtr` * `bun.ptr.WeakPtr` (For internal tracking: fixes STAB-1011)