X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FDynamicThreadPool.html;h=de2edc9d8649f9a8a2c83a1386b686ddedd67699;hb=8d98e603c79d8d00b2b6a33e5f732701a7466234;hp=1a2b41461599d0603fb24da6c2a1d7c4c18d1543;hpb=d61f24ac46792cfab91a154667f24fc57c90e66e;p=poolifier.git diff --git a/docs/classes/DynamicThreadPool.html b/docs/classes/DynamicThreadPool.html index 1a2b4146..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,593 +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.

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

    -
    +
  • Defined in src/pools/abstract-pool.ts:57
  • +
    -
    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

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

    Inherit Doc

    +
  • Defined in src/pools/abstract-pool.ts:67
  • +
    + +
    workerNodes: WorkerNode<ThreadWorkerWithMessageChannel, Data>[] = []
    +

    Pool worker nodes.

    +

    Accessors

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

        Inherit Doc

        +

        Whether the pool is busy or not.

        +

        The pool busyness boolean status.

        +

        Returns boolean

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

      Whether the pool is full or not.

      +

      The pool filling boolean status.

      +
      +

      Returns boolean

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

      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/dynamic.ts:37
  • +
    + +
      +
    • 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

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

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