X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=b1134c0258f8f3382de1f4fc5cf85afb20a8c81a;hb=70353024c44987c467dadcec306c699ce4ae1f06;hp=825204bbd3d233ed273b1f47085036680317246b;hpb=c0b0686de0f8c5483b20b94fac97d2b8175c0556;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 825204bb..b1134c02 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:26
  • @@ -49,350 +51,306 @@

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

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

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

          Parameters

          -
            -
          • -
            data: Data
          -

          Returns Response

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

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

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

    +
  • Defined in src/worker/abstract-worker.ts:52
  • 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:42
  • +
    + +
    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:38
  • +
    -
    mainWorker: undefined | null | MainWorker
    -
    - - +
  • Defined in src/worker/abstract-worker.ts:58
  • +
    + +
    opts: WorkerOptions = ...

    Options for the worker.

    +
  • Defined in src/worker/abstract-worker.ts:59
  • +
    + +
    taskFunctions: Map<string, WorkerFunction<Data, Response>>
    +

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

    +

    Methods

    -
    +
    -
      - +
        +
      • -
        -

        Returns

        The unique asyncId assigned to the resource.

        -
        -

        Returns number

    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:306
  • +
    -
      - +
        +
      • 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.

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

        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

    -
    - -
    +
    + +
      +
    • -

      Check if the fn parameter is passed to the constructor.

      +

      Checks if the taskFunctions parameter is passed to the constructor.

      Parameters

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

        The function that should be defined.

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

            Parameters

            -
              -
            • -
              data: Data
            -

            Returns Response

      +
      taskFunctions: WorkerFunction<Data, Response> | TaskFunctions<Data, Response>
      +

      The task function(s) parameter that should be checked.

      +

    Returns void

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

    Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:86
  • +
    -
    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:302
  • +
    -
    -
    - -
    +
    + +
    -
    - -
    +
    + +
    -

    Returns void

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

    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:174
  • +
    -
    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:311
  • +
    -

    Parameters

    -

    Returns Func & { asyncResource: AsyncResource }

    +
    +
    +
    +

    On This Page

    - -
    +
  • constructor
  • +
  • aliveInterval
  • +
  • isMain
  • +
  • lastTaskTimestamp
  • +
  • mainWorker
  • +
  • opts
  • +
  • taskFunctions
  • +
  • asyncId
  • +
  • bind
  • +
  • checkAlive
  • +
  • checkTaskFunctions
  • +
  • checkWorkerOptions
  • +
  • emitDestroy
  • +
  • getMainWorker
  • +
  • getTaskFunction
  • +
  • handleError
  • +
  • messageListener
  • +
  • runAsync
  • +
  • runInAsyncScope
  • +
  • runSync
  • +
  • sendToMainWorker
  • +
  • triggerAsyncId
  • +
  • bind
  • + +

    Generated using TypeDoc

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