Type Parameters

  • Type

Hierarchy

  • Pool

Constructors

  • Type Parameters

    • Type

    Parameters

    • builder: ((...args: any[]) => Type)
        • (...args: any[]): Type
        • Parameters

          • Rest ...args: any[]

          Returns Type

    • recycler: ((instance: Type, ...args: any[]) => Type)
        • (instance: Type, ...args: any[]): Type
        • Parameters

          • instance: Type
          • Rest ...args: any[]

          Returns Type

    • maxObjects: number = 100

    Returns Pool<Type>

Properties

builder: ((...args: any[]) => Type)

Type declaration

    • (...args: any[]): Type
    • Parameters

      • Rest ...args: any[]

      Returns Type

disableWarnings: boolean = false
index: number = 0
maxObjects: number = 100
objects: Type[] = []
recycler: ((instance: Type, ...args: any[]) => Type)

Type declaration

    • (instance: Type, ...args: any[]): Type
    • Parameters

      • instance: Type
      • Rest ...args: any[]

      Returns Type

totalAllocations: number = 0

Methods

  • Use a single instance out of th pool and immediately return it to the pool

    Parameters

    • context: ((object: Type) => void)
        • (object: Type): void
        • Parameters

          • object: Type

          Returns void

    Returns void

  • Signals we are done with the pool objects for now, Reclaims all objects in the pool.

    If a list of pooled objects is passed to done they are un-hooked from the pool and are free to be passed to consumers

    Parameters

    • Rest ...objects: Type[]

      A list of object to separate from the pool

    Returns Type[]

  • Returns void

  • Retrieve a value from the pool, will allocate a new instance if necessary or recycle from the pool

    Parameters

    • Rest ...args: any[]

    Returns Type

  • Use many instances out of the in the context and return all to the pool.

    By returning values out of the context they will be un-hooked from the pool and are free to be passed to consumers

    Parameters

    • context: ((pool: Pool<Type>) => void | Type[])
        • (pool: Pool<Type>): void | Type[]
        • Parameters

          Returns void | Type[]

    Returns Type[]