X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FThreadWorker.html;h=8b5d3d325dd55c13f829d6cf2400f48bc749cf70;hb=fbc22127e53d3ec0ecbd38ecea25fb92ebef50e7;hp=507f44763b0f7070e43e26c44d8e42a0f198667a;hpb=b142df6d1278e9d0b6c4c7226bf3dae36c486410;p=poolifier.git diff --git a/docs/classes/ThreadWorker.html b/docs/classes/ThreadWorker.html index 507f4476..8b5d3d32 100644 --- a/docs/classes/ThreadWorker.html +++ b/docs/classes/ThreadWorker.html @@ -1,13 +1,15 @@ -ThreadWorker | poolifier
+ThreadWorker | poolifier
-
+
-
+
  • poolifier
  • @@ -20,10 +22,6 @@ 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.

    -

    Template

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

    - -

    Template

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

    -

    Author

    Alessandro Pio Ardizio

    Since

    0.0.1

    @@ -32,17 +30,21 @@ but the minimum number of workers will be guaranteed.

    Type Parameters

    • -

      Data = unknown

    • +

      Data = unknown

      +

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

      +
    • -

      Response = unknown

    +

    Response = unknown

    +

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

    +

Hierarchy

+
  • Defined in src/worker/thread-worker.ts:21
  • @@ -50,37 +52,38 @@ but the minimum number of workers will be guaranteed.

    Constructors

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

        @@ -88,73 +91,72 @@ but the minimum number of workers will be guaranteed.

        Type Parameters

        • -

          Data = unknown

        • +

          Data = unknown

        • -

          Response = unknown

    +

    Response = unknown

    Parameters

    • -
      fn: ((data: Data) => Response)
      +
      fn: WorkerFunction<Data, Response>

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

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

          Parameters

          -
            -
          • -
            data: Data
          -

          Returns Response

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

    Options for the worker.

  • -

    Returns ThreadWorker<Data, Response>

    Properties

    -
    +
    -
    aliveInterval?: Timeout
    -

    Handler Id of the aliveInterval worker alive check.

    +
    aliveInterval?: Timeout
    +

    Handler id of the aliveInterval worker alive check.

    -
    +
  • Defined in src/worker/abstract-worker.ts:36
  • +
    + +
    isMain: boolean
    +

    Whether this is the main worker or not.

    +
    +
    -
    lastTaskTimestamp: number
    +
    lastTaskTimestamp: number

    Timestamp of the last task processed by this worker.

    -
    +
  • Defined in src/worker/abstract-worker.ts:32
  • +
    -
    mainWorker: undefined | null | MessagePort
    -
    - - +
  • Defined in src/worker/abstract-worker.ts:50
  • +
    + +
    opts: WorkerOptions = ...

    Options for the worker.

    +
  • Defined in src/worker/abstract-worker.ts:51
  • Methods

    -
    +
    -
      - +
        +
      • Returns

        The unique asyncId assigned to the resource.

        @@ -162,11 +164,11 @@ but the minimum number of workers will be guaranteed.

        Returns number

    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.11/node_modules/@types/node/async_hooks.d.ts:315
  • +
    -
      - +
        +
      • Binds the given function to execute to this AsyncResource's scope.

        The returned function will have an asyncResource property referencing @@ -178,33 +180,33 @@ the AsyncResource to which the function is bound.

        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 }

    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.11/node_modules/@types/node/async_hooks.d.ts:288
  • +
    -
      - +
    -
    +
  • Defined in src/worker/abstract-worker.ts:156
  • +
    -
      - +
        +
      • 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 @@ -213,29 +215,29 @@ never be called.

        Returns

        A reference to asyncResource.

        -

        Returns ThreadWorker<Data, Response>

    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.11/node_modules/@types/node/async_hooks.d.ts:311
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:139
  • +
    -
      - +
        +
      • -

        Handle an error and convert it to a string so it can be sent back to the main worker.

        +

        Handles an error and convert it to a string so it can be sent back to the main worker.

        Returns

        Message of the error.

        @@ -243,110 +245,83 @@ never be called.

        Parameters

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

          The error raised by the worker.

        Returns string

    -
    +
  • Defined in src/worker/abstract-worker.ts:171
  • +
    -
      - +
        +
      • +

        Worker message listener.

        +

        Parameters

        • -
          value: MessageValue<Data, MessagePort>
        • -
        • -
          fn: ((data: Data) => Response)
          -
            -
          • -
              -
            • (data: Data): Response
            • -
            • -
              -

              Parameters

              -
                +
                message: MessageValue<Data, MessagePort>
                +

                Message received.

                +
              • -
                data: Data
              -

              Returns Response

        +
        fn: WorkerFunction<Data, Response>
        +

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

        +

    Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:89
  • +
    -
      - +
        +
      • -

        Run the given function synchronously.

        +

        Runs the given function synchronously.

        Parameters

        • -
          fn: ((data?: Data) => Response)
          +
          fn: WorkerSyncFunction<Data, Response>

          Function that will be executed.

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

              Parameters

              -
                -
              • -
                Optional data: Data
              -

              Returns Response

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

        Input data for the given function.

    Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:181
  • +
    -

    Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:208
  • +
    -
    +

    Result

    Parameters

    +

    Returns Result

  • -
    Optional thisArg: This
    +
    Optional thisArg: This

    The receiver to be used for the function call.

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

    Optional arguments to pass to the function.

  • -

    Returns Result

    +
    -
    -
    +
  • Defined in src/worker/thread-worker.ts:39
  • +
    -
    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.11/node_modules/@types/node/async_hooks.d.ts:320
  • +
    -
    +

    ThisArg

    Parameters

    -

    Returns Func & { asyncResource: AsyncResource }

    +
    +
    +
    +

    On This Page

    - -
    +
  • constructor
  • +
  • aliveInterval
  • +
  • isMain
  • +
  • lastTaskTimestamp
  • +
  • mainWorker
  • +
  • opts
  • +
  • asyncId
  • +
  • bind
  • +
  • checkAlive
  • +
  • emitDestroy
  • +
  • getMainWorker
  • +
  • handleError
  • +
  • messageListener
  • +
  • run
  • +
  • runAsync
  • +
  • runInAsyncScope
  • +
  • sendToMainWorker
  • +
  • triggerAsyncId
  • +
  • bind
  • + +

    Generated using TypeDoc

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