X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=df85f6680ee4b5899780ee0f36af115abac21d0c;hb=fbc22127e53d3ec0ecbd38ecea25fb92ebef50e7;hp=825204bbd3d233ed273b1f47085036680317246b;hpb=c0b0686de0f8c5483b20b94fac97d2b8175c0556;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 825204bb..df85f668 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

@@ -49,39 +51,40 @@

Constructors

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

      @@ -89,83 +92,81 @@

      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.

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

        @@ -173,11 +174,11 @@

        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 @@ -189,73 +190,62 @@ 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
  • +
    -
      - +
        +
      • -

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

    Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:110
  • +
    -
    -
    +
  • 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
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:171
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:89
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:181
  • +
    -
    -
    +
  • 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/abstract-worker.ts:151
  • +
    -
    -
    +
  • 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
  • +
  • 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