X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FFixedThreadPool.html;h=c7d211d68f6016a1c3c32768bec4adf1f576cf00;hb=184d530faf6acf70e116cb4a3fb831938b73e2c0;hp=57265e609f7b34bbbea60218553d07ed0907f5fb;hpb=7cd8af0033b35def46016a78ea9be1ee516480bf;p=poolifier.git diff --git a/docs/classes/FixedThreadPool.html b/docs/classes/FixedThreadPool.html index 57265e60..c7d211d6 100644 --- a/docs/classes/FixedThreadPool.html +++ b/docs/classes/FixedThreadPool.html @@ -1,4 +1,4 @@ -FixedThreadPool | poolifier
+FixedThreadPool | poolifier
-
+
-
+

Type Parameters

-
    +
    • -

      Data = unknown

      +

      Data = unknown

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

    • -

      Response = unknown

      -

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

      +

      Response = unknown

      +

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

Hierarchy

+
  • Defined in src/pools/thread/fixed.ts:34
  • @@ -52,494 +52,592 @@

    Constructors

    -
    +
    -
      - +
        +
      • Constructs a new poolifier fixed thread pool.

        -
        +

        Type Parameters

        -
          +
          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

    Parameters

    -

    Returns FixedThreadPool<Data, Response>

    +
  • Defined in src/pools/thread/fixed.ts:45
  • Properties

    -
    +
    -
    emitter?: PoolEmitter
    -
    -

    Inherit Doc

    -
    - -
    filePath: string
    -

    Path to the worker-file.

    +
    emitter?: PoolEmitter
    +

    Emitter on which events can be listened to.

    +

    Events that can currently be listened to:

    +
      +
    • 'full': Emitted when the pool is dynamic and full.
    • +
    • 'busy': Emitted when the pool is busy.
    • +
    • 'error': Emitted when an uncaught error occurs.
    • +
    • 'taskError': Emitted when an error occurs while executing a task.
    • +
    +
    +
    + +
    filePath: string
    +

    Path to the worker file.

    -
    - -
    numberOfWorkers: number
    +
  • Defined in src/pools/abstract-pool.ts:82
  • +
    + +
    numberOfWorkers: number

    Number of workers that this pool should manage.

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

    Options for the pool.

    -
    +
  • Defined in src/pools/abstract-pool.ts:83
  • +
    -
    promiseResponseMap: Map<string, PromiseResponseWrapper<ThreadWorkerWithMessageChannel, Response>> = ...
    -

    The promise response map.

    +
    promiseResponseMap: Map<string, PromiseResponseWrapper<ThreadWorkerWithMessageChannel, Response>> = ...
    +

    The execution response promise map.

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

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

    +

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

    -
    +
  • Defined in src/pools/abstract-pool.ts:57
  • +
    -
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
    +
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>

    Worker choice strategy context referencing a worker choice algorithm implementation.

    Default to a round robin algorithm.

    -
    - -
    workers: WorkerType<ThreadWorkerWithMessageChannel>[] = []
    -
    -

    Inherit Doc

    +
    + +
    workerNodes: WorkerNode<ThreadWorkerWithMessageChannel, Data>[] = []
    +

    Pool worker nodes.

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

    -
    - -
    +
    + +
    • get full(): boolean
    • -
      -

      Inherit Doc

      +

      Whether the pool is full or not.

      +

      The pool filling boolean status.

      +

      Returns boolean

    -
    - -
    +
    + +
    +
    + +
      +
    • get maxSize(): number
    • -

      Number of tasks concurrently running in the pool.

      +

      Pool maximum size.

      Returns number

    -
    - -
    +
    + +
      +
    • get minSize(): number
    • -
      -

      Inherit Doc

      -

      Returns PoolType

    +
    + +
      +
    • get type(): "fixed" | "dynamic"
    • +
    • +

      Pool type.

      +

      If it is 'dynamic', it provides the max property.

      +
      +

      Returns "fixed" | "dynamic"

    +
  • Defined in src/pools/thread/fixed.ts:100
  • +
    + +
      +
    • get worker(): "cluster" | "thread"
    • +
    • +

      Gets the worker type.

      +
      +

      Returns "cluster" | "thread"

    Methods

    -
    - -
    +
    -
      - +
        +
      • -
        -

        Inherit Doc

        +

        Function that can be hooked up when a worker has been newly created and moved to the pool worker nodes.

        +

        Can be used to update the maxListeners or binding the main-worker<->worker connection if not bind by default.

        +

        Parameters

        +
        worker: ThreadWorkerWithMessageChannel
        +

        The newly created worker.

        +

    Returns void

    -
    - -
    +
    + +
      +
    • -

      Hook executed before the worker task promise resolution. +

      Hook executed before the worker task execution. Can be overridden.

      Parameters

      • -
        workerKey: number
        -

        The worker key.

        +
        workerNodeKey: number
        +

        The worker node key.

      Returns void

    -
    - -
    +
    + +
      +
    • -

      Chooses a worker for the next task.

      -

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

      - -

      Returns

      [worker key, worker].

      +

      Chooses a worker node for the next task.

      +

      The default worker choice strategy uses a round robin algorithm to distribute the load.

      -

      Returns [number, ThreadWorkerWithMessageChannel]

    -
    +
  • Defined in src/pools/abstract-pool.ts:532
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:596
  • +
    -
    -
    +
  • Defined in src/pools/thread/fixed.ts:83
  • +
    -
      - +
    -
    - -
    +
    + +
    +

    Returns Promise<void>

    +
    + +
      + +
    • +

      Enables/disables the worker tasks queue in this pool.

      +
      +
      +

      Parameters

      +
        +
      • +
        enable: boolean
        +

        Whether to enable or disable the worker tasks queue.

        +
      • +
      • +
        Optional tasksQueueOptions: TasksQueueOptions
        +

        The worker tasks queue options.

        +
      +

      Returns void

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

        Inherit Doc

        +

        Executes the specified function in the worker constructor with the task data input parameter.

        +

        Parameters

        • -
          data: Data
        -

        Returns Promise<Response>

    -
    - -
      - -
    • -
      -

      Inherit Doc

      -

      Returns number

    • +
    • +
      Optional name: string
      +

      The name of the worker function to execute. If not specified, the default worker function will be executed.

      +
    +

    Returns Promise<Response>

    Promise that will be fulfilled when the task is completed.

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

    Parameters

    Returns void

    Returns void

    -
    - -
    +
    + +
    -
    - -
    +
    + +

    Returns void

    -
    +
  • Defined in src/pools/abstract-pool.ts:337
  • +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:284
  • +
    + +
    +
    -
    -
    +
  • Defined in src/pools/abstract-pool.ts:438
  • +
    -
    - +

    Returns void

    The listener function to execute when a message is received from a worker.

    + +
    +
    +
    +

    On This Page

    - -
    +
  • constructor
  • +
  • emitter
  • +
  • filePath
  • +
  • numberOfWorkers
  • +
  • opts
  • +
  • promiseResponseMap
  • +
  • workerChoiceStrategyContext
  • +
  • workerNodes
  • +
  • busy
  • +
  • full
  • +
  • info
  • +
  • maxSize
  • +
  • minSize
  • +
  • type
  • +
  • worker
  • +
  • afterTaskExecutionHook
  • +
  • afterWorkerSetup
  • +
  • beforeTaskExecutionHook
  • +
  • chooseWorkerNode
  • +
  • createAndSetupWorker
  • +
  • createWorker
  • +
  • destroy
  • +
  • destroyWorker
  • +
  • enableTasksQueue
  • +
  • execute
  • +
  • internalBusy
  • +
  • isMain
  • +
  • registerWorkerMessageListener
  • +
  • sendToWorker
  • +
  • setTasksQueueOptions
  • +
  • setWorkerChoiceStrategy
  • +
  • setWorkerChoiceStrategyOptions
  • +
  • setupHook
  • +
  • workerListener
  • + +

    Generated using TypeDoc

    -
    \ No newline at end of file +
    \ No newline at end of file