X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=388b91568f37a8f74f3a04cc4cbbcdb3faba48bf;hb=afc34f0c8ee4e44ba301212a5eed3fb01035b1fb;hp=0cc3eca18900fc85ad2f3b0104e151ef4d19ffff;hpb=7e36fa9f0f844e3e60f0c22de3e28665dd8cc9d1;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 0cc3eca1..388b9156 100644 --- a/docs/classes/AbstractWorker.html +++ b/docs/classes/AbstractWorker.html @@ -1,4 +1,4 @@ -AbstractWorker | poolifier
+AbstractWorker | poolifier
-

Returns AbstractWorker<MainWorker, Data, Response>

Properties

-
+
-
aliveInterval?: Timeout
+
aliveInterval?: Timeout

Handler id of the aliveInterval worker alive check.

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

    Reference to main worker.

    -
    +
  • Defined in src/worker/abstract-worker.ts:50
  • +
    -
    opts: WorkerOptions = ...
    +
    opts: WorkerOptions = ...

    Options for the worker.

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

    -
    +
    -
      - +
        +
      • Returns

        The unique asyncId assigned to the resource.

        @@ -186,10 +175,10 @@

        Inherited from AsyncResource.asyncId

        • 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 @@ -201,32 +190,32 @@ 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 src/worker/abstract-worker.ts:156
  • +
    -
      - +
        +
      • Checks if the fn parameter is passed to the constructor.

        @@ -234,40 +223,29 @@ the AsyncResource to which the function is bound.

        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
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:110
  • +
    -
      - +
        +
      • 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 @@ -276,26 +254,26 @@ never be called.

        Returns

        A reference to asyncResource.

        -

        Returns AbstractWorker<MainWorker, Data, Response>

    -
    +
    -
      - +
        +
      • Returns the main worker.

        Returns

        Reference to the main worker.

        -

        Returns MainWorker

    -
    +
  • Defined in src/worker/abstract-worker.ts:139
  • +
    -
      - +
        +
      • Handles an error and convert it to a string so it can be sent back to the main worker.

        @@ -305,16 +283,16 @@ 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.

        @@ -322,31 +300,20 @@ never be called.

        Parameters

        • -
          message: MessageValue<Data, MainWorker>
          +
          message: MessageValue<Data, MainWorker>

          Message received.

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

        +

      Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:89
  • +
    -
      - +
        +
      • Runs the given function synchronously.

        @@ -354,31 +321,20 @@ never be called.

        Parameters

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

          Function that will be executed.

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

              Parameters

              -
                -
              • -
                Optional data: Data
              -

              Returns Response

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

          Input data for the given function.

        Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:181
  • +
    -
      - +
        +
      • Runs the given function asynchronously.

        @@ -386,31 +342,20 @@ never be called.

        Parameters

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

          Function that will be executed.

          -
          -
            -
          • -
              -
            • (data?: Data): Promise<Response>
            • -
            • -
              -

              Parameters

              -
                -
              • -
                Optional data: Data
              -

              Returns Promise<Response>

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

          Input data for the given function.

        Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:208
  • +
    -
      - +
        +
      • Call the provided function with the provided arguments in the execution context of the async resource. This will establish the context, trigger the AsyncHooks @@ -423,45 +368,45 @@ then restore the original execution context.

        Type Parameters

        • -

          This

        • +

          This

        • -

          Result

    +

    Result

    Parameters

    • -
      fn: ((this: This, ...args: any[]) => Result)
      +
      fn: ((this, ...args) => Result)

      The function to call in the execution context of this async resource.

      • -
          -
        • (this: This, ...args: any[]): Result
        • +
            +
          • (this, ...args): Result
          • Parameters

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

            Returns Result

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

    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

    +
    -
      - +
        +
      • Returns

        The same triggerAsyncId that is passed to the AsyncResource constructor.

        @@ -487,10 +432,10 @@ then restore the original execution context.

        Inherited from AsyncResource.triggerAsyncId

        • Defined in node_modules/.pnpm/@types+node@18.15.11/node_modules/@types/node/async_hooks.d.ts:320
    -
    +
    -
      - +
        +
      • Binds the given function to the current execution context.

        The returned function will have an asyncResource property referencing @@ -502,23 +447,23 @@ the AsyncResource to which the function is bound.

        Type Parameters

        • -

          Func extends ((this: ThisArg, ...args: any[]) => any)

        • +

          Func extends ((this, ...args) => any)

        • -

          ThisArg

    +

    ThisArg

    Parameters

    • -
      fn: Func
      +
      fn: Func

      The function to bind to the current execution context.

    • -
      Optional type: string
      +
      Optional type: string

      An optional name to associate with the underlying AsyncResource.

    • -
      Optional thisArg: ThisArg
    -

    Returns Func & {
        asyncResource: AsyncResource;
    }