API Reference

util.Pool Class

Defined in lib/util/pool.js:15

Description

Thread pool.

Constructor

util.Pool

(worker, [concurrency])
Defined in lib/util/pool.js:15

Thread pool.

Parameters

  • worker String
  • concurrency Number optional

    Default to the number of CPUs.

Methods

_insert

(tasks, first, [callback]) private
Defined in lib/util/pool.js:88

Inserts a task to the pool.

Parameters

end

Terminates all workers.

length

Number

Returns the number of pending tasks.

Returns

process

private

Starts distributing tasks to each worker.

push

(tasks, [callback])

Adds a task to last of queue.

Parameters

unshift

(tasks, [callback])

Adds a task to first of queue.

Parameters

Properties

concurrency

Defined in lib/util/pool.js:47

Concurrency.

drain

Defined in lib/util/pool.js:56

This function is invoked when the last task in the pool is done.

empty

Defined in lib/util/pool.js:74

This function is invoked when the last task in the pool is started.

saturated

Defined in lib/util/pool.js:65

This function is invoked when the number of pending tasks equals to the concurrency of the pool.

tasks

private
Defined in lib/util/pool.js:27

Tasks.

workers

private
Defined in lib/util/pool.js:37

Workers.