Skip to main content

Pool <T>

@deprecated

Use ArenaPool

Hierarchy

Index

Constructors

constructor

  • Pool<T>(builder: () => T, recycler?: (instance: T) => T, maxObjects?: number): Pool<T>
  • Type parameters

    • T

    Parameters

    • builder: () => T
      • optionalrecycler: (instance: T) => T
        • maxObjects: number = 100

        Returns Pool<T>

      Properties

      publicinheritedbuilder

      builder: () => T

      Type declaration

        • (): T
        • Returns T

      publicinheriteddisableWarnings

      disableWarnings: boolean = false

      publicinheritedindex

      index: number = 0

      publicinheritedmaxObjects

      maxObjects: number = 100

      publicinheritedobjects

      objects: T[] = []

      publicoptionalinheritedrecycler

      recycler?: (instance: T) => T

      Type declaration

        • (instance: T): T
        • Parameters

          • instance: T

          Returns T

      publicinheritedtotalAllocations

      totalAllocations: number = 0

      Methods

      inheritedborrow

      • borrow(context: (object: T) => void): void
      • Use a single instance out of th pool and immediately return it to the pool


        Parameters

        • context: (object: T) => void

          Returns void

        inheriteddispose

        • dispose(): void
        • Returns void

        inheriteddone

        • done(...objects: T[]): T[]
        • done(): 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: T[]

            A list of object to separate from the pool

          Returns T[]

        inheritedget

        • get(): T
        • Retrieve a value from the pool, will allocate a new instance if necessary or recycle from the pool


          Returns T

        inheritedpreallocate

        • preallocate(): void
        • Returns void

        inheritedusing

        • using(context: (pool: ArenaPool<T>) => void | T[]): T[]
        • 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

          Returns T[]