export { GcRegistry }; type CloseFn = () => void | Promise; /** * GC-tracked cleanup with two reclaim paths: * * 1. **FinalizationRegistry** — primary path. Fires when the engine notices the * target is unreachable. Timing is engine-defined and can be deferred * indefinitely (especially for ephemeron cycles or under low GC pressure). * * 2. **Periodic WeakRef scan** — fallback. Walks all entries on a fixed * interval, calls `deref()` on each, and fires cleanup if the WeakRef has * been collected but the FinalizationRegistry callback hasn't run yet. * * Both paths funnel into the same idempotent `fireCleanup`, so neither double-runs. * * The scan timer runs **only while entries are tracked** — it starts on the first * `register()` and stops once the set empties. So a single shared instance keeps no * timer when idle: an isolate with nothing tracked (e.g. a Cloudflare Durable Object * with no open callback/stream channels) has no pending work and can hibernate. */ declare class GcRegistry { private readonly periodicScanMs; private finalReg; private entries; private scanTimer; constructor(periodicScanMs?: number); register(target: object, close: CloseFn): void; private scan; private fireCleanup; private stopScanIfIdle; }