X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=b1134c0258f8f3382de1f4fc5cf85afb20a8c81a;hb=70353024c44987c467dadcec306c699ce4ae1f06;hp=bf014c7de22dde23a93900e54c77018f549ad35d;hpb=6c7b620077f30f365d597b7fce35cfe5584c2702;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index bf014c7d..b1134c02 100644 --- a/docs/classes/AbstractWorker.html +++ b/docs/classes/AbstractWorker.html @@ -1,13 +1,15 @@ -AbstractWorker | poolifier
+AbstractWorker | poolifier
-
+
-
+
  • poolifier
  • @@ -16,32 +18,32 @@

    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,318 +51,285 @@

    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.

    +
    +
    + +
    isMain: boolean
    +

    Whether this is the main worker or not.

    -
    +
  • Defined in src/worker/abstract-worker.ts:54
  • +
    -
    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

    -
    - -
    +
    + +
      +
    • -

      Checks 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
  • +
    -
      - +
        +
      • 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 AbstractWorker<MainWorker, Data, Response>

    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:302
  • +
    -
      - +
        +
      • Returns the main worker.

        - -

        Returns

        Reference to the main worker.

        -

        Returns MainWorker

    -
    - -
    +
    + +
      +
    • -

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

      - -

      Returns

      Message of the error.

      +

      Gets the task function in the given scope.

      Parameters

      • -
        e: string | Error
        -

        The error raised by the worker.

        +
        Optional name: string
        +

        Name of the function that will be returned.

      -

      Returns string

    -
    - -
      - -
    • -
      -

      Parameters

      -
    +
    + +
      +
    • +

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

      +

      Parameters

      • -
        data: Data
      -

      Returns Response

    -

    Returns void

    +

    Returns string

    Message of the error.

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