Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DLLObjectPool<Value>

Class which manages a pool of object resources.
Internal implementation is based on 2 Doubly Linked Lists, one for free resources, and another for used ones.

Type parameters

  • Value

Hierarchy

  • DLLObjectPool

Constructors

constructor

Accessors

stats

Methods

acquire

  • acquire(...args: any[]): Readonly<Node<Value>>
  • Acquire a new object resource from pool.
    This operation has O(1) complexity.

    throws

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

    Parameters

    • Rest ...args: any[]

      Arguments forwarded to object: - constructor (when resource is acquired for the first time) - initializer (when resource is reused)

    Returns Readonly<Node<Value>>

    Handle to object resource.

preempt

  • preempt(object: Value): Readonly<Node<Value>>
  • Preempts an object resource which initially wasn't managed by this DLLObjectPool.
    After preemption, object will be put into used resources list.
    This operation has O(1) complexity.

    Parameters

    • object: Value

      Object resource.

    Returns Readonly<Node<Value>>

    Handle to object resource that was preempted.

releaseAll

  • releaseAll(): void
  • Release all object resources.
    This method has O(n) complexity, because it needs to iterate over all used resources to free them (i.e. call their destructors).

    Returns void

releaseHandle

  • releaseHandle(handle: Node<Undefinable<Value>>): void
  • Release handle to object resource.
    This operation has O(1) complexity.

    Parameters

    • handle: Node<Undefinable<Value>>

      Handle to object resource.

    Returns void

releaseObject

  • releaseObject(object: Value): void
  • Release object resource
    This method has O(n) complexity, because we need to find according handle for that object resource before performing release.

    Parameters

    • object: Value

      Object resource.

    Returns void

Static value

  • value<V>(handle: Node<V>): V
  • Obtain value of the handle to object resource.

    Type parameters

    • V

    Parameters

    • handle: Node<V>

      Handle to object resource.

    Returns V

    Object resource from the handle.