X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FFixedClusterPool.html;h=9847d27bb0985464f3107e0da0c777aa4541db01;hb=0770fe626b2bb3212a1d73fa4764973ac92e241a;hp=5e4adf05eeb4282930373887bdcaca42041520fa;hpb=e83f3916315e18f3ca0c614d6ec9e064ab76c13c;p=poolifier.git diff --git a/docs/classes/FixedClusterPool.html b/docs/classes/FixedClusterPool.html index 5e4adf05..9847d27b 100644 --- a/docs/classes/FixedClusterPool.html +++ b/docs/classes/FixedClusterPool.html @@ -1,11 +1,13 @@ FixedClusterPool | poolifier
-
+
@@ -18,10 +20,6 @@

It is possible to perform tasks in sync or asynchronous mode as you prefer.

This pool selects the workers in a round robin fashion.

-

Template

of data sent to the worker. This can only be serializable data.

- -

Template

of response of execution. This can only be serializable data.

-

Author

Christopher Quadflieg

Since

2.0.0

@@ -30,9 +28,13 @@

Type Parameters

  • -

    Data = unknown

  • +

    Data = unknown

    +

    Type of data sent to the worker. This can only be serializable data.

    +
  • -

    Response = unknown

+

Response = unknown

+

Type of response of execution. This can only be serializable data.

+

Hierarchy

+
  • Defined in src/pools/cluster/fixed.ts:39
  • @@ -56,39 +58,32 @@

    Properties

    Accessors

    Methods

    -
    afterPromiseWorkerResponseHook +
    afterPromiseResponseHook afterWorkerSetup -beforePromiseWorkerResponseHook +beforePromiseResponseHook chooseWorker createAndSetupWorker createWorker destroy destroyWorker execute -findFreeWorker -getWorkerAverageTasksRunTime -getWorkerIndex -getWorkerRunningTasks -initWorkerTasksUsage -internalExecute -internalGetBusyStatus +findFreeWorkerKey +internalBusy isMain registerWorkerMessageListener removeWorker @@ -102,7 +97,7 @@
      - +
    • Constructs a new poolifier fixed cluster pool.

      @@ -125,70 +120,60 @@

      Path to an implementation of a ClusterWorker file, which can be relative or absolute.

    • -
      Optional opts: ClusterPoolOptions = {}
      +
      opts: ClusterPoolOptions = {}

      Options for this fixed cluster pool.

    Returns FixedClusterPool<Data, Response>

    +
  • Defined in src/pools/cluster/fixed.ts:50
  • Properties

    -
    emitter?: PoolEmitter
    -
    -

    Inherit Doc

    +
  • Defined in src/pools/abstract-pool.ts:32
  • -
    filePath: string
    -
    - -
    max?: number
    -
    -

    Inherit Doc

    -
    - -
    nextMessageId: number = 0
    -

    Id of the next message.

    +
    filePath: string
    +

    Path to the worker-file.

    +
  • Defined in src/pools/abstract-pool.ts:67
  • -
    numberOfWorkers: number
    +
  • Defined in src/pools/abstract-pool.ts:66
  • -
    -
    - -
    promiseMap: Map<number, PromiseWorkerResponseWrapper<Worker, Response>> = ...
    -

    The promise map.

    +
  • Defined in src/pools/cluster/fixed.ts:53
  • +
    + +
    promiseResponseMap: Map<string, PromiseResponseWrapper<Worker, Response>> = ...
    +

    The promise response map.

      -
    • key: This is the message Id of each submitted task.
    • -
    • value: An object that contains the worker, the resolve function and the reject function.
    • +
    • key: The message id of each submitted task.
    • +
    • value: An object that contains the worker, the promise resolve and reject callbacks.
    -

    When we receive a message from the worker we get a map entry and resolve/reject the promise based on the message.

    +

    When we receive a message from the worker we get a map entry with the promise resolve/reject bound to the message.

    +
  • Defined in src/pools/abstract-pool.ts:42
  • workerChoiceStrategyContext: WorkerChoiceStrategyContext<Worker, Data, Response>
    @@ -197,23 +182,15 @@
    +
  • Defined in src/pools/abstract-pool.ts:52
  • -
    workers: Worker[] = []
    -
    -

    Inherit Doc

    -
    - -
    workersTasksUsage: Map<Worker, TasksUsage> = ...
    -
    -

    Inherit Doc

    +
  • Defined in src/pools/abstract-pool.ts:29
  • Accessors

    @@ -221,40 +198,51 @@
    -
    - -
    +
    + +
    +
    + +
    • get numberOfRunningTasks(): number
    • -
      -

      Inherit Doc

      +

      Number of tasks concurrently running.

      +

      Returns number

    +
  • Defined in src/pools/abstract-pool.ts:149
  • +
  • Defined in src/pools/cluster/fixed.ts:99
  • Methods

    -
    - +
    +
      - +
    • Hook executed after the worker task promise resolution. Can be overridden.

      @@ -263,24 +251,24 @@ Can be overridden.

      Parameters

      • -
        message: MessageValue<Response, unknown>
        -

        The received message.

        +
        worker: Worker
        +

        The worker.

      • -
        promise: PromiseWorkerResponseWrapper<Worker, Response>
        -

        The Promise response.

        +
        message: MessageValue<Response, unknown>
        +

        The received message.

      Returns void

    +
  • Defined in src/pools/abstract-pool.ts:263
    • -
      -

      Inherit Doc

      +

      {@inheritDoc}

      +

      Parameters

    -
    - +
  • Defined in src/pools/cluster/fixed.ts:93
  • +
    +
      - +
    • Hook executed before the worker task promise resolution. Can be overridden.

      @@ -302,27 +290,27 @@ Can be overridden.

      Parameters

      • -
        worker: Worker
        -

        The worker.

        +
        workerKey: number
        +

        The worker key.

      Returns void

    +
  • Defined in src/pools/abstract-pool.ts:252
    • - +
    • Chooses a worker for the next task.

      The default implementation uses a round robin algorithm to distribute the load.

      -

      Returns

      Worker.

      +

      Returns

      [worker key, worker].

      -

      Returns Worker

    +
  • Defined in src/pools/abstract-pool.ts:303
  • +
  • Defined in src/pools/abstract-pool.ts:348
    • -
      -

      Inherit Doc

      +

      {@inheritDoc}

      +

      Returns Worker

    +
  • Defined in src/pools/cluster/fixed.ts:88
    • -
      -

      Inherit Doc

      +

      {@inheritDoc}

      +

      Returns Promise<void>

    +
  • Defined in src/pools/abstract-pool.ts:218
    • -
      -

      Inherit Doc

      +

      {@inheritDoc}

      +

      Parameters

    +
  • Defined in src/pools/cluster/fixed.ts:69
    • -
      -

      Inherit Doc

      +

      {@inheritDoc}

      +

      Parameters

    -
    - -
      - -
    • -
      -

      Inherit Doc

      -

      Returns false | Worker

    -
    - -
      - -
    • -
      -

      Inherit Doc

      -
      -

      Parameters

      -
        -
      • -
        worker: Worker
      -

      Returns undefined | number

    -
    - -
      - -
    • -
      -

      Inherit Doc

      -
      -

      Parameters

      -
        -
      • -
        worker: Worker
      -

      Returns number

    -
    - +
  • Defined in src/pools/abstract-pool.ts:203
  • +
    +
      - +
    • -
      -

      Inherit Doc

      -
      -

      Parameters

      -
        -
      • -
        worker: Worker
      -

      Returns undefined | number

    -
    - -
      - -
    • -

      Initializes tasks usage statistics.

      +

      {@inheritDoc}

      -
      -

      Parameters

      -
        -
      • -
        worker: Worker
        -

        The worker.

        -
      -

      Returns void

    -
    - -
      - -
    • -
      -

      Parameters

      -
        -
      • -
        worker: Worker
      • -
      • -
        messageId: number
      -

      Returns Promise<Response>

    -
    - +
  • Defined in src/pools/abstract-pool.ts:196
  • +
    +
      - +
    • Returns boolean

    +
  • Defined in src/pools/abstract-pool.ts:188
  • +
  • Defined in src/pools/cluster/fixed.ts:64
    • -
      -

      Inherit Doc

      +

      {@inheritDoc}

      +

      Type Parameters

        @@ -536,7 +442,7 @@ Can be overridden.

        Returns void

      +
    • Defined in src/pools/cluster/fixed.ts:80
      @@ -549,19 +455,19 @@ Can be overridden.

      • worker: Worker
        -

        Worker that will be removed.

        +

        The worker that will be removed.

    Returns void

    +
  • Defined in src/pools/abstract-pool.ts:290
  • +
  • Defined in src/pools/cluster/fixed.ts:75
  • Returns void

    +
  • Defined in src/pools/abstract-pool.ts:164
  • +
  • Defined in src/pools/cluster/fixed.ts:59
  • +
  • Defined in src/pools/abstract-pool.ts:377