Options
All
  • Public
  • Public/Protected
  • All
Menu

Default thread pool implementation that processes the scheduled functions in FIFO order.

Hierarchy

  • DefaultThreadPool

Implements

Index

Constructors

constructor

Properties

Private idleWorkers

idleWorkers: IWorkerThread[] = []

Private maxThreadsLimit

maxThreadsLimit: number

Private queue

queue: WorkerTask<any>[] = []

Private workerThreadFactory

workerThreadFactory: IWorkerThreadFactory

Private workers

workers: IWorkerThread[] = []

Accessors

maxThreads

  • get maxThreads(): number
  • set maxThreads(limit: number): void

Methods

Private releaseWorker

run

Private runTaskOnWorker

  • Starts the given task on the given worker. Resolves the task when the computation succeeds, rejects it otherwise. The task is resolved when the computation has succeeded or is rejected if the computation failed

    Parameters

    • task: WorkerTask<any>

      the task to run on the given worker

    • worker: IWorkerThread

      the worker to use to execute the task

    Returns void

Private schedulePendingTasks

  • schedulePendingTasks(): void
  • Schedules the tasks in the queue onto the available workers. A new worker is spawned when no more idle workers are available and the number of workers has not yet reached the concurrency limit. If no more idle workers are available and the concurrency limit has been reached then the tasks are left in queue.

    Returns void

Generated using TypeDoc