import { CleanupFn, Factory, ItemCleanupPair } from "@isograph/disposable-types"; //#region src/CacheItem.d.ts type NotInParentCacheAndDisposed = { kind: 'NotInParentCacheAndDisposed'; }; type NotInParentCacheAndNotDisposed = { kind: 'NotInParentCacheAndNotDisposed'; value: T; disposeValue: () => void; permanentRetainCount: number; }; type InParentCacheAndNotDisposed = { kind: 'InParentCacheAndNotDisposed'; value: T; disposeValue: () => void; removeFromParentCache: () => void; temporaryRetainCount: number; permanentRetainCount: number; }; type CacheItemState = InParentCacheAndNotDisposed | NotInParentCacheAndNotDisposed | NotInParentCacheAndDisposed; type CacheItemOptions = { temporaryRetainTime: number; }; /** * CacheItem: * * Terminology: * - TRC = Temporary Retain Count * - PRC = Permanent Retain Count * * A CacheItem can be in three states: * In parent cache? | Item disposed? | TRC | PRC | Name * -----------------+----------------+-----+-----+------------------------------- * In parent cache | Not disposed | >0 | >=0 | InParentCacheAndNotDisposed * Removed | Not disposed | 0 | >0 | NotInParentCacheAndNotDisposed * Removed | Disposed | 0 | 0 | NotInParentCacheAndNotDisposed * * A cache item can only move down rows. As in, if its in the parent cache, * it can be removed. It can never be replaced in the parent cache. (If a * parent cache becomes full again, it will contain a new CacheItem.) The * contained item can be disposed, but never un-disposed. * * So, the valid transitions are: * - InParentCacheAndNotDisposed => NotInParentCacheAndNotDisposed * - InParentCacheAndNotDisposed => NotInParentCacheAndDisposed * - NotInParentCacheAndNotDisposed => NotInParentCacheAndDisposed */ declare class CacheItem { private __state; private __options; constructor(factory: Factory, removeFromParentCache: CleanupFn, options: CacheItemOptions | void); getValue(): T; permanentRetainIfNotDisposed(disposeOfTemporaryRetain: CleanupFn): ItemCleanupPair | null; temporaryRetain(): CleanupFn; permanentRetain(): CleanupFn; private __maybeExitInParentCacheAndNotDisposedState; private __maybeExitNotInParentCacheAndNotDisposedState; } declare function createTemporarilyRetainedCacheItem(factory: Factory, removeFromParentCache: CleanupFn, options: CacheItemOptions | void): [CacheItem, CleanupFn]; //#endregion export { CacheItem, CacheItemOptions, CacheItemState, InParentCacheAndNotDisposed, NotInParentCacheAndDisposed, NotInParentCacheAndNotDisposed, createTemporarilyRetainedCacheItem }; //# sourceMappingURL=CacheItem.d.mts.map