X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FThreadWorker.html;h=8b5d3d325dd55c13f829d6cf2400f48bc749cf70;hb=fbc22127e53d3ec0ecbd38ecea25fb92ebef50e7;hp=38c5a5908d1d266e6b70201adcd9a5b9272ff772;hpb=a8aeac440fb425585a0d597af86f616e648ae156;p=poolifier.git diff --git a/docs/classes/ThreadWorker.html b/docs/classes/ThreadWorker.html index 38c5a590..8b5d3d32 100644 --- a/docs/classes/ThreadWorker.html +++ b/docs/classes/ThreadWorker.html @@ -1,4 +1,4 @@ -ThreadWorker | poolifier
+ThreadWorker | poolifier
-

Returns ThreadWorker<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 | MessagePort
    +
    mainWorker: undefined | null | MessagePort

    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.

        @@ -176,10 +165,10 @@ but the minimum number of workers will be guaranteed.

        Inherited from AbstractWorker.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 @@ -191,33 +180,33 @@ 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
  • +
    -
      - +
        +
      • 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 @@ -226,27 +215,27 @@ never be called.

        Returns

        A reference to asyncResource.

        -

        Returns ThreadWorker<Data, Response>

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

        @@ -256,17 +245,17 @@ 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.

        @@ -274,32 +263,21 @@ never be called.

        Parameters

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

          Message received.

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

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

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

              Parameters

              -
                -
              • -
                data: Data
              -

              Returns Response | Promise<Response>

    +

    Returns void

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

        @@ -307,32 +285,21 @@ 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.

        @@ -340,32 +307,21 @@ 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 @@ -378,45 +334,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.

        @@ -443,10 +399,10 @@ then restore the original execution context.

        Inherited from AbstractWorker.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 @@ -458,23 +414,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;
    }