X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=b1134c0258f8f3382de1f4fc5cf85afb20a8c81a;hb=70353024c44987c467dadcec306c699ce4ae1f06;hp=54dc548553d2a01d5c21dd7912ab72f738da3f7d;hpb=761b0c73be0bf581f50a78123913f933bd405f52;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 54dc5485..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: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.

      +

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

      Parameters

      • -
        message: MessageValue<Data, MainWorker>
        -

        Message received.

        -
      • -
      • -
        fn: WorkerFunction<Data, Response>
        -

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

        +
        e: string | Error
        +

        The error raised by the worker.

      -

      Returns void

    -
    - -
    +
    + +
      +
    • -

      Runs the given function synchronously.

      +

      Worker message listener.

      Parameters

      • -
        fn: WorkerSyncFunction<Data, Response>
        -

        Function that will be executed.

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

    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 @@ -364,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.

        @@ -414,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