X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=b1134c0258f8f3382de1f4fc5cf85afb20a8c81a;hb=70353024c44987c467dadcec306c699ce4ae1f06;hp=4ab8a26e71a842599ee5d0c50003bbbb4bd7f466;hpb=d49303bcd1dc86f36030dff08796f869681d4eae;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 4ab8a26e..b1134c02 100644 --- a/docs/classes/AbstractWorker.html +++ b/docs/classes/AbstractWorker.html @@ -1,4 +1,4 @@ -AbstractWorker | poolifier
+AbstractWorker | poolifier

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

    -
    - -
    +
    + +
      +
    • -

      Worker message listener.

      -
      -
      -

      Parameters

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

        Message received.

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

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

        +

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

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

            • -
              data: Data
            -

            Returns Response

      -

      Returns void

    +

    Returns string

    Message of the error.

    +
    -
    - -
    +
    + +
      +
    • -

      Runs the given function synchronously.

      -
      -
      -

      Parameters

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

        Function that will be executed.

        +

        Worker message listener.

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

            • -
              Optional data: Data
            -

            Returns Response

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

        Input data for the given function.

        +
        message: MessageValue<Data, MainWorker>
        +

        Message received.

      Returns void

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

        @@ -386,31 +337,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, Worker | MessagePort>

          Input data for the given function.

        Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:233
  • +
    -
      - +
        +
      • Call the provided function with the provided arguments in the execution context of the async resource. This will establish the context, trigger the AsyncHooks @@ -419,49 +359,70 @@ then restore the original execution context.

        Since

        v9.6.0

        -
        +

        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

    +
    + +
      + +
    • +

      Runs the given function synchronously.

      +
      +
      +

      Parameters

      +
        +
      • +
        fn: WorkerSyncFunction<Data, Response>
        +

        Function that will be executed.

        +
      • +
      • +
        message: MessageValue<Data, Worker | MessagePort>
        +

        Input data for the given function.

        +
      +

      Returns void

    +
    -
      - +
        +
      • Sends a message to the main worker.

        @@ -469,59 +430,56 @@ then restore the original execution context.

        Parameters

        • -
          message: MessageValue<Response, unknown>
          +
          message: MessageValue<Response, Worker | MessagePort>

          The response message.

        Returns void

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

        Returns

        The same triggerAsyncId that is passed to the AsyncResource constructor.

        -
        -

        Returns number

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

        -

        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 ((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;
    }

    +

    Theme

    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
  • +
  • PoolType
  • +
  • AbstractPool
  • +
  • AbstractWorker
  • +
  • CircularArray
  • +
  • ClusterWorker
  • +
  • DynamicClusterPool
  • +
  • DynamicThreadPool
  • +
  • FixedClusterPool
  • +
  • FixedThreadPool
  • +
  • PoolEmitter
  • +
  • Queue
  • +
  • ThreadWorker
  • +
  • WorkerChoiceStrategyContext
  • +
  • ClusterPoolOptions
  • +
  • IPool
  • +
  • IWorker
  • +
  • IWorkerChoiceStrategy
  • +
  • MessageValue
  • +
  • PoolOptions
  • +
  • PromiseResponseWrapper
  • +
  • RequiredStatistics
  • +
  • Task
  • +
  • TasksQueueOptions
  • +
  • TasksUsage
  • +
  • WorkerChoiceStrategyOptions
  • +
  • WorkerNode
  • +
  • WorkerOptions
  • +
  • Draft
  • +
  • ErrorHandler
  • +
  • ExitHandler
  • +
  • KillBehavior
  • +
  • MessageHandler
  • +
  • OnlineHandler
  • +
  • PoolEvent
  • +
  • TaskFunctions
  • +
  • ThreadWorkerWithMessageChannel
  • +
  • WorkerAsyncFunction
  • +
  • WorkerChoiceStrategy
  • +
  • WorkerFunction
  • +
  • WorkerSyncFunction
  • +
  • KillBehaviors
  • +
  • PoolEvents
  • +
  • WorkerChoiceStrategies
  • Generated using TypeDoc

    \ No newline at end of file