X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FAbstractWorker.html;h=18a43c17ff5ece1893951dc02c853071665114b0;hb=749e1fa387ba832c85f789337b3c2e679331cb64;hp=171b0c64063e4b200ea46b40bdd890fe8b835bf3;hpb=53221c4e8cbcc585c670275e7c1c700c3d1b5f37;p=poolifier.git diff --git a/docs/classes/AbstractWorker.html b/docs/classes/AbstractWorker.html index 171b0c64..18a43c17 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.

        -
        -

        Returns number

    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.13/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 @@ -197,36 +185,36 @@ 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@18.15.13/node_modules/@types/node/async_hooks.d.ts:288
  • +
    -
      - +
    -
    +
  • Defined in src/worker/abstract-worker.ts:156
  • +
    -
      - +
        +
      • Checks if the fn parameter is passed to the constructor.

        @@ -234,87 +222,73 @@ the AsyncResource to which the function is bound.

        Parameters

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

          The function that should be defined.

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

              Parameters

              -
                -
              • -
                data: Data
              -

              Returns Response | Promise<Response>

    +

    Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:95
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:83
  • +
    -
      - +
        +
      • 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@18.15.13/node_modules/@types/node/async_hooks.d.ts:311
  • +
    -
      - +
        +
      • 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.

        - -

        Returns

        Message of the error.

        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 +296,20 @@ never be called.

        Parameters

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

          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:113
  • +
    -
      - +
        +
      • Runs the given function synchronously.

        @@ -354,31 +317,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 +338,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 @@ -419,49 +360,49 @@ 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

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

        @@ -469,28 +410,27 @@ then restore the original execution context.

        Parameters

        Returns void

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

        Returns

        The same triggerAsyncId that is passed to the AsyncResource constructor.

        -
        -

        Returns number

    -
    +
  • Defined in node_modules/.pnpm/@types+node@18.15.13/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 @@ -498,30 +438,30 @@ 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
  • +
  • asyncId
  • +
  • bind
  • +
  • checkAlive
  • +
  • checkFunctionInput
  • +
  • checkWorkerOptions
  • +
  • emitDestroy
  • +
  • getMainWorker
  • +
  • handleError
  • +
  • messageListener
  • +
  • run
  • +
  • runAsync
  • +
  • runInAsyncScope
  • +
  • sendToMainWorker
  • +
  • triggerAsyncId
  • +
  • bind
  • +
  • PoolType
  • +
  • AbstractPool
  • +
  • AbstractWorker
  • +
  • CircularArray
  • +
  • ClusterWorker
  • +
  • DynamicClusterPool
  • +
  • DynamicThreadPool
  • +
  • FixedClusterPool
  • +
  • FixedThreadPool
  • +
  • PoolEmitter
  • +
  • ThreadWorker
  • +
  • WorkerChoiceStrategyContext
  • +
  • ClusterPoolOptions
  • +
  • IPool
  • +
  • IWorker
  • +
  • IWorkerChoiceStrategy
  • +
  • MessageValue
  • +
  • PoolOptions
  • +
  • PromiseResponseWrapper
  • +
  • RequiredStatistics
  • +
  • Task
  • +
  • TasksQueueOptions
  • +
  • TasksUsage
  • +
  • WorkerChoiceStrategyOptions
  • +
  • WorkerNode
  • +
  • WorkerOptions
  • +
  • Draft
  • +
  • ErrorHandler
  • +
  • ExitHandler
  • +
  • KillBehavior
  • +
  • MessageHandler
  • +
  • OnlineHandler
  • +
  • PoolEvent
  • +
  • ThreadWorkerWithMessageChannel
  • +
  • WorkerAsyncFunction
  • +
  • WorkerChoiceStrategy
  • +
  • WorkerFunction
  • +
  • WorkerSyncFunction
  • +
  • KillBehaviors
  • +
  • PoolEvents
  • +
  • WorkerChoiceStrategies
  • Generated using TypeDoc

    \ No newline at end of file