Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ArrayObjectPool<T>

Pool of object resources.
The internal implementation keeps resources into a single {@link Array}.
This implementation has advantage over DLLObjectPool, as it consumes less memory, while keeping operations complexity constant.

Type parameters

  • T: ObjMap

    Type of the object.

Hierarchy

  • ArrayObjectPool

Constructors

Accessors

Methods

Constructors

constructor

Accessors

free

  • get free(): number
  • Get number of free resources.

    Returns number

used

  • get used(): number
  • Get number of used resources.

    Returns number

Methods

acquire

  • Acquire a new object resource from pool.
    This operation has O(1) complexity.

    throws

    {Exception} When number of used resources goes beyond ArrayObjectPoolOptions.capacity.

    Parameters

    • Rest ...args: any[]

      Arguments forwarded to object initializer.

    Returns Readonly<ObjectResource<T>>

    Object resource.

clear

  • clear(): void
  • Clears the object resources pool.
    After this operation, pool should no longer be used.
    This operation has O(1) complexity.

    IMPORTANT! This method won't call destructors of the resources, it will only reset internal storage of resources

    Returns void

release

  • Release object resource.
    This operation has O(1) complexity.

    Parameters

    Returns void

releaseAll

  • releaseAll(): void
  • Release all object resources.
    Notice that objects won't be de-allocated, only their destructors will be called.
    This operation has O(n) complexity.

    Returns void