CCC Docs
    Preparing search index...

    Class OwnerRefCount<T>

    A reference-counted Owner for a shared value.

    The source ownership is disposed after the final OwnerRefCount is disposed. Each clone owns one reference and can be disposed independently.

    const controller = new AbortController();
    const first = OwnerRefCount.new(
    controller,
    (controller) => controller.abort(),
    );
    const second = first.clone();

    await first.dispose();
    console.log(controller.signal.aborted); // false

    await second.dispose();
    console.log(controller.signal.aborted); // true

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index
    • get value(): T

      The owned value.

      Returns T

      If this ownership has been moved or disposed.

    • Returns whether a value implements CCC Owner semantics.

      Parameters

      • value: unknown

      Returns value is Owner<unknown>

    • Maps the owned value while transferring this ownership claim.

      The mapper runs before the claim is moved, so a mapper failure leaves this Owner active. After a successful mapping, this Owner is invalidated and the returned Owner retains its release semantics.

      Type Parameters

      • U

      Parameters

      • mapper: (value: T) => U

      Returns Owner<U>

    • Moves the ownership claim out of this owner without disposing it.

      Access is invalidated synchronously and the moved claim retains this Owner's release semantics.

      Returns OwnerMoved<T>

      If this owner no longer has an ownership claim.

    • Creates the first reference-counted Owner for a value.

      Type Parameters

      • T

      Parameters

      • value: T
      • disposer: (value: T) => void | PromiseLike<void>

      Returns OwnerRefCount<T>

    • Releases this ownership claim.

      Implementations decide whether this disposes the value immediately or, for example, only decrements a reference count.

      Returns void | Promise<void>