X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=18a43c17ff5ece1893951dc02c853071665114b0;hb=749e1fa387ba832c85f789337b3c2e679331cb64;hp=825204bbd3d233ed273b1f47085036680317246b;hpb=c0b0686de0f8c5483b20b94fac97d2b8175c0556;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 825204bb..18a43c17 100644 --- a/docs/classes/AbstractWorker.html +++ b/docs/classes/AbstractWorker.html @@ -1,47 +1,49 @@ -AbstractWorker | poolifier
+AbstractWorker | poolifier
-
+
-
+

Class AbstractWorker<MainWorker, Data, Response>Abstract

-

Base class containing some shared logic for all poolifier workers.

+

Base class that implements some shared logic for all poolifier workers.

-
+

Type Parameters

-
    +
    • -

      MainWorker extends Worker | MessagePort

      +

      MainWorker extends Worker | MessagePort

      Type of main worker.

    • -

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

Hierarchy

+
  • Defined in src/worker/abstract-worker.ts:24
  • @@ -49,135 +51,133 @@

    Constructors

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

        -
        +

        Type Parameters

        -
          +
          • -

            MainWorker extends Worker | MessagePort

          • +

            MainWorker extends Worker | MessagePort

          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

    Parameters

    • -
      type: string
      +
      type: string

      The type of async event.

    • -
      isMain: boolean
      +
      isMain: boolean

      Whether this is the main worker or not.

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

    • +
  • -
    mainWorker: undefined | null | MainWorker
    +
    mainWorker: undefined | null | MainWorker

    Reference to main worker.

  • -
    opts: WorkerOptions = ...
    +
    opts: WorkerOptions = ...

    Options for the worker.

  • -

    Returns AbstractWorker<MainWorker, Data, Response>

    Properties

    -
    +
    -
    aliveInterval?: Timeout
    -

    Handler Id of the aliveInterval worker alive check.

    +
    aliveInterval?: Timeout
    +

    Handler id of the aliveInterval worker alive check.

    +
    +
    + +
    isMain: boolean
    +

    Whether this is the main worker or not.

    -
    +
  • Defined in src/worker/abstract-worker.ts:48
  • +
    -
    lastTaskTimestamp: number
    +
    lastTaskTimestamp: number

    Timestamp of the last task processed by this worker.

    -
    +
  • Defined in src/worker/abstract-worker.ts:32
  • +
    -
    mainWorker: undefined | null | MainWorker
    -
    - - +
  • 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.

        -
        -

        Returns number

    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.13/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 @@ -185,214 +185,173 @@ the AsyncResource to which the function is bound.

        Since

        v14.8.0, v12.19.0

        -
        +

        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.13/node_modules/@types/node/async_hooks.d.ts:288
  • +
    -
      - +
        +
      • -

        Check to see if the worker should be terminated, because its living too long.

        +

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

        Returns void

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

        Check if the fn parameter is passed to the constructor.

        +

        Checks if the fn parameter is passed to the constructor.

        Parameters

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

          The function that should be defined.

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

              Parameters

              -
                -
              • -
                data: Data
              -

              Returns Response

        +

    Returns void

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

    Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:83
  • +
    -
    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/async_hooks.d.ts:311
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:139
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:171
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:113
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:181
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:208
  • +
    -

    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/abstract-worker.ts:151
  • +
    -
    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.13/node_modules/@types/node/async_hooks.d.ts:320
  • +
    -

    Parameters

    -

    Returns Func & { asyncResource: AsyncResource }

    +
    +
    +
    +

    On This Page

    - -
    +
  • constructor
  • +
  • aliveInterval
  • +
  • isMain
  • +
  • lastTaskTimestamp
  • +
  • mainWorker
  • +
  • opts
  • +
  • asyncId
  • +
  • bind
  • +
  • checkAlive
  • +
  • checkFunctionInput
  • +
  • checkWorkerOptions
  • +
  • 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