2.0.4 • Published 6 months ago

@types/worker-threads-pool v2.0.4

Weekly downloads
28
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/worker-threads-pool

Summary

This package contains type definitions for worker-threads-pool (https://github.com/watson/worker-threads-pool#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/worker-threads-pool.

index.d.ts

// Type definitions for worker-threads-pool 2.0
// Project: https://github.com/watson/worker-threads-pool#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />

import { Worker, WorkerOptions } from 'worker_threads';

export = Pool;

declare class Pool {
    constructor(options?: Pool.Options);

    /**
     * Number of active workers in the pool.
     */
    size: number;

    /**
     * @param filename argument passed directly to `new Worker(filename, options)`
     * @param options argument passed directly to `new Worker(filename, options)`
     * @param callback will be called once the worker is created
     */
    acquire(filename: string, callback: (error: Error | null, worker: Worker) => void): void;
    acquire(
        filename: string,
        options: WorkerOptions,
        callback: (error: Error | null, worker: Worker) => void
    ): void;

    /**
     * Calls `worker.terminate()` on all workers in the pool.
     * @param callback will be called once all workers have terminated
     */
    destroy(callback?: () => void): void;
}

declare namespace Pool {
     interface Options {
        /**
         * Maximum number of workers allowed in the pool. Other workers will be queued
         * and started once there's room in the pool.
         * @default 1
         */
        max?: number | undefined;
        /**
         * Maximum number of workers waiting to be started when the pool is full.
         * The callback to `pool.acquire` will be called with an error in case this limit is reached.
         */
        maxWaiting?: number | undefined;
    }
}

Additional Details

Credits

These definitions were written by BendingBender.

2.0.3

7 months ago

2.0.2

8 months ago

2.0.4

6 months ago

2.0.1

3 years ago

2.0.0

5 years ago