X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FThreadWorker.html;h=3fcf96a7f322699507cb4f27b3eedb00ed8b4421;hb=95d287d1625c80929657a9f217774c5c8f6668e7;hp=d432e78534adfbf6482a685f243b588ba35a1507;hpb=69f8ce0ab8ce1afcf350b21796496b8dcd2aaec1;p=poolifier.git diff --git a/docs/classes/ThreadWorker.html b/docs/classes/ThreadWorker.html index d432e785..7dcea1ef 100644 --- a/docs/classes/ThreadWorker.html +++ b/docs/classes/ThreadWorker.html @@ -1,4 +1,4 @@ -ThreadWorker | poolifier
+ThreadWorker | poolifier - v2.6.41
  • Preparing search index...
  • -
  • The search index is not available
poolifier
+
  • The search index is not available
  • poolifier - v2.6.41
    -
    +
    • poolifier
    • @@ -21,30 +21,33 @@ it will send a termination request to its main thread.

      If you use a DynamicThreadPool the extra workers that were created will be terminated, but the minimum number of workers will be guaranteed.

      +
    +
    +

    Author

    Alessandro Pio Ardizio

    -

    Author

    Alessandro Pio Ardizio

    - -

    Since

    0.0.1

    +

    Since

    0.0.1

    -
    +

    Type Parameters

    -
      +
      • -

        Data = unknown

        -

        Type of data this worker receives from pool's execution. This can only be serializable data.

        -
      • +

        Data = unknown

        +

        Type of data this worker receives from pool's execution. This can only be structured-cloneable data.

        +
        +
      • -

        Response = unknown

        -

        Type of response the worker sends back to the main thread. This can only be serializable data.

        -
    +

    Response = unknown

    +

    Type of response the worker sends back to the main thread. This can only be structured-cloneable data.

    +
    +

    Hierarchy

      -
    • AbstractWorker<MessagePort, Data, Response> +
    • AbstractWorker<MessagePort, Data, Response>
      • ThreadWorker
    +
  • Defined in src/worker/thread-worker.ts:26
  • @@ -52,417 +55,621 @@ but the minimum number of workers will be guaranteed.

    Constructors

    -
    - -
      - +
      + +
        +
      • Constructs a new poolifier thread worker.

        -
        +

        Type Parameters

        -
          +
          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

      Parameters

      • -
        fn: ((data: Data) => Response)
        -

        Function processed by the worker when the pool's execution function is invoked.

        -
        -
          -
        • -
            -
          • (data: Data): Response
          • -
          • -
            -

            Parameters

            -
              -
            • -
              data: Data
            -

            Returns Response

      • +
        taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>
        +

        Task function(s) processed by the worker when the pool's execution function is invoked.

        +
      • -
        opts: WorkerOptions = {}
        +
        opts: WorkerOptions = {}

        Options for the worker.

      -

      Returns ThreadWorker<Data, Response>

    +
  • Defined in src/worker/thread-worker.ts:40
  • Properties

    -
    - -
    aliveInterval?: Timeout
    -

    Handler Id of the aliveInterval worker alive check.

    -
    +
    + +
    isMain: boolean
    +

    Whether this is the main worker or not.

    +
    +
    +
    + +
    lastTaskTimestamp: number

    Timestamp of the last task processed by this worker.

    -
    -
    - -
    mainWorker: undefined | null | MessagePort
    -
    - - +
    +
    +
    + +
    opts: WorkerOptions = DEFAULT_WORKER_OPTIONS

    Options for the worker.

    -
    +
    +
    + +
    port: MessagePort
    +

    Message port used to communicate with the main worker.

    +
    +
    +
  • Defined in src/worker/thread-worker.ts:33
  • +
    + +
    statistics: WorkerStatistics
    +

    Performance statistics computation requirements.

    +
    +
    +
    + +
    taskFunctions: Map<string, TaskFunction<Data, Response>>
    +

    Task function(s) processed by the worker when the pool's execution function is invoked.

    +
    +
    +
    +

    Accessors

    +
    + +

    Methods

    -
    - -
    +
    + +
      +
    • -

      Binds the given function to execute to this AsyncResource's scope.

      -

      The returned function will have an asyncResource property referencing -the AsyncResource to which the function is bound.

      +

      Returns number

      The unique asyncId assigned to the resource.

      -

      Since

      v14.8.0, v12.19.0

      +
    +
    + +
      + +
    • +

      Binds the given function to execute to this AsyncResource's scope.

      -
      +

      Type Parameters

      -
        +
        • -

          Func extends ((...args: any[]) => any)

      +

      Func extends ((...args) => any)

    Parameters

    • -
      fn: Func
      +
      fn: Func

      The function to bind to the current AsyncResource.

    -

    Returns Func & {
        asyncResource: AsyncResource;
    }

    -
    - -
      - -
    • -

      Checks if the worker should be terminated, because its living too long.

      -
      -

      Returns void

    -
    - -
      - +
    • Defined in node_modules/.pnpm/@types+node@20.5.9/node_modules/@types/node/async_hooks.d.ts:283
    +
    + +
      +
    • Call all destroy hooks. This should only ever be called once. An error will be thrown if it is called more than once. This must be manually called. If the resource is left to be collected by the GC then the destroy hooks will never be called.

      - -

      Returns

      A reference to asyncResource.

      -

      Returns ThreadWorker<Data, Response>

    -
    - -
      - +
    • Defined in node_modules/.pnpm/@types+node@20.5.9/node_modules/@types/node/async_hooks.d.ts:302
    +
    + +
    -
    - -
    +
    + +
      +
    • Handles an error and convert it to a string so it can be sent back to the main worker.

      - -

      Returns

      Message of the error.

      Parameters

      • -
        e: string | Error
        +
        e: string | Error

        The error raised by the worker.

      -

      Returns string

    -
    - -
    +
    + +
    +
    + +
      +
    • +

      Handles the ready message sent by the main worker.

      +

      Parameters

      • -
        data: Data
      -

      Returns Response

    -

    Returns void

    +
    + +
    +
    + +
    +
    + + -
  • -
    value: MessageValue<Data, unknown>
    -

    Input data for the given function.

    +
    message: MessageValue<Data, unknown>
    +

    The received message.

  • -

    Returns void

    -
    - -
    +
    + +
    +
    + +
    +
    + + +
    fn: TaskAsyncFunction<Data, Response>
    +

    Task function that will be executed.

    +
  • -
    value: MessageValue<Data, unknown>
    -

    Input data for the given function.

    +
    task: Task<Data>
    +

    Input data for the task function.

  • -

    Returns void

    -
    - -
    +
    + +

    Parameters

    +

    Returns Result

  • -
    Optional thisArg: This
    +
    Optional thisArg: This

    The receiver to be used for the function call.

    -
  • +Optional
  • -
    Rest ...args: any[]
    +
    Rest ...args: any[]

    Optional arguments to pass to the function.

    +
    Rest
  • +

    Returns Result

    +
    +

    Since

    v9.6.0

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

    Returns void

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

    Parameters

    Optional
  • -
    Optional thisArg: ThisArg
  • -

    Returns Func & {
        asyncResource: AsyncResource;
    }

    +
    +
    +
    +

    On This Page

    - -
    -

    Generated using TypeDoc

    -
    \ No newline at end of file +
  • constructor
  • +
  • activeInterval
  • +
  • isMain
  • +
  • lastTaskTimestamp
  • +
  • opts
  • +
  • port
  • +
  • statistics
  • +
  • taskFunctions
  • +
  • id
  • +
  • addTaskFunction
  • +
  • asyncId
  • +
  • bind
  • +
  • emitDestroy
  • +
  • getMainWorker
  • +
  • handleError
  • +
  • handleKillMessage
  • +
  • handleReadyMessage
  • +
  • hasTaskFunction
  • +
  • listTaskFunctions
  • +
  • messageListener
  • +
  • removeTaskFunction
  • +
  • run
  • +
  • runAsync
  • +
  • runInAsyncScope
  • +
  • runSync
  • +
  • sendTaskFunctionsListToMainWorker
  • +
  • sendToMainWorker
  • +
  • setDefaultTaskFunction
  • +
  • triggerAsyncId
  • +
  • bind
  • + +
    +

    Generated using TypeDoc

    +
    \ No newline at end of file