X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=docs%2Fclasses%2FDynamicThreadPool.html;h=de2edc9d8649f9a8a2c83a1386b686ddedd67699;hb=8d98e603c79d8d00b2b6a33e5f732701a7466234;hp=b7fba0c61ae31aaa5d6a377084a30609ae4b1385;hpb=c0b0686de0f8c5483b20b94fac97d2b8175c0556;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index b7fba0c6..de2edc9d 100644 --- a/docs/classes/DynamicThreadPool.html +++ b/docs/classes/DynamicThreadPool.html @@ -1,13 +1,15 @@ -DynamicThreadPool | poolifier
+DynamicThreadPool | poolifier
-
+
-
+
  • poolifier
  • @@ -16,31 +18,31 @@

    A thread pool with a dynamic number of threads, but a guaranteed minimum number of threads.

    This thread pool creates new threads when the others are busy, up to the maximum number of threads. -When the maximum number of threads is reached, an event is emitted. If you want to listen to this event, use the pool's emitter.

    - -

    Template

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

    - -

    Template

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

    +When the maximum number of threads is reached and workers are busy, an event is emitted. If you want to listen to this event, use the pool's emitter.

    Author

    Alessandro Pio Ardizio

    Since

    0.0.1

    -
    +

    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 execution response. This can only be serializable data.

    +

Hierarchy

+
  • Defined in src/pools/thread/dynamic.ts:15
  • @@ -48,551 +50,604 @@ When the maximum number of threads is reached, an event is emitted. If you want

    Constructors

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

        -
        +

        Type Parameters

        -
          +
          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

    Parameters

    • -
      min: number
      +
      min: number

      Minimum number of threads which are always active.

    • -
      max: number
      +
      max: number

      Maximum number of threads that can be created by this pool.

    • -
      filePath: string
      +
      filePath: string

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

    • -
      Optional opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}
      +
      opts: PoolOptions<ThreadWorkerWithMessageChannel> = {}

      Options for this dynamic thread pool.

    -

    Returns DynamicThreadPool<Data, Response>

    +
  • Defined in src/pools/thread/dynamic.ts:27
  • Properties

    -
    +
    -
    emitter?: PoolEmitter
    -
    -

    Inherit Doc

    -
    - -
    filePath: string
    +
    + +
    filePath: string
    +

    Path to the worker file.

    +
    -
    - -
    max: number
    -
    -

    Inherit Doc

    -
    - -
    nextMessageId: number = 0
    -

    Id of the next message.

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

    Maximum number of threads that can be created by this pool.

    -
    - -
    numberOfWorkers: number
    +
    + +
    numberOfWorkers: number
    +

    Number of workers that this pool should manage.

    +
    -
    - -
    +
    + + +

    Options for the pool.

    +
    -
    - -
    promiseMap: Map<number, PromiseWorkerResponseWrapper<ThreadWorkerWithMessageChannel, Response>> = ...
    -

    The promise map.

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

    The execution response promise 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 execution response 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 id.

    -
    - -
    tasks: Map<ThreadWorkerWithMessageChannel, number> = ...
    -
    -

    Inherit Doc

    -
    +

    Inherited from FixedThreadPool.promiseResponseMap

    +
    +
    -
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
    -

    Worker choice strategy instance implementing the worker choice algorithm.

    -

    Default to a strategy implementing a round robin algorithm.

    +
    workerChoiceStrategyContext: WorkerChoiceStrategyContext<ThreadWorkerWithMessageChannel, Data, Response>
    +

    Worker choice strategy context referencing a worker choice algorithm implementation.

    +

    Default to a round robin algorithm.

    -
    - - -
    -

    Inherit Doc

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

    Pool worker nodes.

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

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

        Inherit Doc

        +

        Whether the pool is busy or not.

        +

        The pool busyness boolean status.

        +

        Returns boolean

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

      Inherit Doc

      -

      Returns number

    -
    - -
    +
    + +
    -
    -

    Methods

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

    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

      -

      Returns Promise<void>

    +

    Returns void

    -
    - -
    +
    + +
      +
    • -
      -

      Inherit Doc

      +

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

      +

      Parameters

      • -
        data: Data
      -

      Returns Promise<Response>

    +

    Returns void

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

    Returns Promise<void>

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

    Returns Promise<Response>

    Promise that will be fulfilled when the task is completed.

    + +
    + +
    -
    +
  • 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
  • +
    -
    - +
    +
    +
    +

    On This Page

    - -
    +
  • constructor
  • +
  • emitter
  • +
  • filePath
  • +
  • max
  • +
  • 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