Hyperlinkv0.8.0-beta.28

RcMap

RcMap.Statetypeeffect/RcMap.ts:99
State<K, A, E>

Represents the internal state of an RcMap, which can be either Open (active) or Closed (shutdown and no longer accepting operations).

When to use

Use when typing code that inspects an RcMap's state field and narrows between open and closed lifecycle states.

modelsRcMapState.OpenState.Closed
Source effect/RcMap.ts:9967 lines
export type State<K, A, E> = State.Open<K, A, E> | State.Closed

/**
 * Namespace containing the internal state types for RcMap.
 *
 * **When to use**
 *
 * Use when referring to the concrete open, closed, and entry state shapes used
 * by `RcMap`.
 *
 * @since 4.0.0
 */
export declare namespace State {
  /**
   * Represents the open/active state of an RcMap, containing the actual
   * resource map that stores entries.
   *
   * **When to use**
   *
   * Use when handling an `RcMap` that can still accept operations and contains
   * stored entries.
   *
   * @category models
   * @since 4.0.0
   */
  export interface Open<K, A, E> {
    readonly _tag: "Open"
    readonly map: MutableHashMap.MutableHashMap<K, Entry<A, E>>
  }

  /**
   * Represents the closed state of an RcMap, indicating that the map has been
   * shut down and will no longer accept new operations.
   *
   * **When to use**
   *
   * Use when handling an `RcMap` after its owning scope has closed.
   *
   * @category models
   * @since 4.0.0
   */
  export interface Closed {
    readonly _tag: "Closed"
  }

  /**
   * Represents an individual entry in the RcMap, containing the resource's
   * metadata including reference count, expiration time, and lifecycle management.
   *
   * **When to use**
   *
   * Use when inspecting the stored resource, reference count, and idle lifecycle
   * metadata for a single key.
   *
   * @category models
   * @since 4.0.0
   */
  export interface Entry<A, E> {
    readonly deferred: Deferred.Deferred<A, E>
    readonly scope: Scope.Closeable
    readonly finalizer: Effect.Effect<void>
    readonly idleTimeToLive: Duration.Duration
    fiber: Fiber.Fiber<void> | undefined
    expiresAt: number
    refCount: number
  }
}
Referenced by 2 symbols