X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FThreadWorker.html;h=cffee599edbc9c129576b25fb261046c49a99f52;hb=b667be1103b9362ae29d094de05f812468464d4f;hp=48dfe83b952cbd0d9165f335252bb39938c52f6d;hpb=699db3f06500e28320ae786e304c23020dd5b5ad;p=poolifier.git diff --git a/docs/classes/ThreadWorker.html b/docs/classes/ThreadWorker.html index 48dfe83b..cffee599 100644 --- a/docs/classes/ThreadWorker.html +++ b/docs/classes/ThreadWorker.html @@ -1,4 +1,4 @@ -ThreadWorker | poolifier
+ThreadWorker | poolifier - v2.6.8
  • Preparing search index...
  • -
  • The search index is not available
poolifier
+
  • The search index is not available
  • poolifier - v2.6.8
    @@ -21,30 +21,33 @@ it will send a termination request to its main thread.

    If you use a DynamicThreadPool the extra workers that were created will be terminated, but the minimum number of workers will be guaranteed.

    +
    +
    +

    Author

    Alessandro Pio Ardizio

    -

    Author

    Alessandro Pio Ardizio

    - -

    Since

    0.0.1

    +

    Since

    0.0.1

    -
    +

    Type Parameters

    -
      +
      • -

        Data = unknown

        -

        Type of data this worker receives from pool's execution. This can only be serializable data.

        -
      • +

        Data = unknown

        +

        Type of data this worker receives from pool's execution. This can only be structured-cloneable data.

        +
        +
      • -

        Response = unknown

        -

        Type of response the worker sends back to the main thread. This can only be serializable data.

        -
    +

    Response = unknown

    +

    Type of response the worker sends back to the main thread. This can only be structured-cloneable data.

    +
    +

    Hierarchy

    +
  • Defined in src/worker/thread-worker.ts:26
  • @@ -52,210 +55,257 @@ but the minimum number of workers will be guaranteed.

    Constructors

    -
    - -
      - +
      + +
        +
      • Constructs a new poolifier thread worker.

        -
        +

        Type Parameters

        -
          +
          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

      Parameters

      • -
        fn: WorkerFunction<Data, Response>
        -

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

        -
      • +
        taskFunctions: WorkerFunction<Data, Response> | TaskFunctions<Data, Response>
        +

        Task function(s) processed by the worker when the pool's execution function is invoked.

        +
        +
      • -
        opts: WorkerOptions = {}
        +
        opts: WorkerOptions = {}

        Options for the worker.

        -
      -

      Returns ThreadWorker<Data, Response>

    +
    +

    Returns ThreadWorker<Data, Response>

    +
    +
  • Defined in src/worker/thread-worker.ts:36
  • Properties

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

    Handler id of the aliveInterval worker alive check.

    -
    -
    - -
    isMain: boolean
    +
  • Defined in src/worker/abstract-worker.ts:58
  • +
    + +
    isMain: boolean

    Whether this is the main worker or not.

    -
    -
    - -
    lastTaskTimestamp: number
    +
  • Defined in src/worker/abstract-worker.ts:70
  • +
    + +
    lastTaskTimestamp: number

    Timestamp of the last task processed by this worker.

    -
    -
    - -
    mainWorker: undefined | null | MessagePort
    +
  • Defined in src/worker/abstract-worker.ts:50
  • +
    + +
    mainWorker: MessagePort

    Reference to main worker.

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

    Options for the worker.

    -
    +
  • Defined in src/worker/abstract-worker.ts:75
  • +
    + +
    statistics: WorkerStatistics
    +

    Performance statistics computation requirements.

    +
    +
    +
    + +
    taskFunctions: Map<string, WorkerFunction<Data, Response>>
    +

    Task function(s) processed by the worker when the pool's execution function is invoked.

    +
    +
    -

    Methods

    -
    - -
      - +

      Accessors

      +
      + +
        +
      • get id(): number
      • -
        -

        Returns

        The unique asyncId assigned to the resource.

        +

        Worker id.

        -

        Returns number

    +
    +

    Methods

    +
    + +
      + +
    • +

      Returns number

      The unique asyncId assigned to the resource.

      + +
    -
    - -
      - +
    • Defined in node_modules/.pnpm/@types+node@20.4.0/node_modules/@types/node/async_hooks.d.ts:306
    +
    + +
      +
    • Binds the given function to execute to this AsyncResource's scope.

      -

      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 ((...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@20.4.0/node_modules/@types/node/async_hooks.d.ts:283
    +
    + +
    -
    - -
    +
    + +
      +
    • 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 ThreadWorker<Data, Response>

    -
    - -
      - +
    • Defined in node_modules/.pnpm/@types+node@20.4.0/node_modules/@types/node/async_hooks.d.ts:302
    +
    + +
    -
    - -
    +
    + +
      +
    • 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

    +

    Returns string

    The error message.

    + +
    -
    - -
    +
    + +
    -
    - - +

    Returns void

    +
    -
    - -
    +
    + +
      +
    • Runs the given function asynchronously.

      @@ -307,72 +333,104 @@ never be called.

      Parameters

      -

      Returns void

    +

    Returns void

    +
    -
    - -
    +
    + +
      +
    • Call the provided function with the provided arguments in the execution context of the async resource. This will establish the context, trigger the AsyncHooks before callbacks, call the function, trigger the AsyncHooks after callbacks, and 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

    -
    - -
    +
    + +
    +
    + + +

    Returns void

    +
    -
    - -
    +
    + +
    -
    - -
    +
    + +

    Parameters

    +
  • -
    Optional type: string
    +
    Optional type: string

    An optional name to associate with the underlying AsyncResource.

    -
  • + +
  • -
    Optional thisArg: ThisArg
  • -

    Returns Func & {
        asyncResource: AsyncResource;
    }

    -

    On This Page

    +

    On This Page

    +
  • constructor
  • +
  • aliveInterval
  • +
  • isMain
  • +
  • lastTaskTimestamp
  • +
  • mainWorker
  • +
  • opts
  • +
  • statistics
  • +
  • taskFunctions
  • +
  • id
  • +
  • asyncId
  • +
  • bind
  • +
  • checkAlive
  • +
  • emitDestroy
  • +
  • getMainWorker
  • +
  • handleError
  • +
  • messageListener
  • +
  • runAsync
  • +
  • runInAsyncScope
  • +
  • runSync
  • +
  • sendToMainWorker
  • +
  • triggerAsyncId
  • +
  • bind
  • +
  • AbstractPool
  • +
  • AbstractWorker
  • +
  • CircularArray
  • +
  • ClusterWorker
  • +
  • DynamicClusterPool
  • +
  • DynamicThreadPool
  • +
  • FixedClusterPool
  • +
  • FixedThreadPool
  • +
  • PoolEmitter
  • +
  • Queue
  • +
  • ThreadWorker
  • +
  • WorkerChoiceStrategyContext
  • +
  • ClusterPoolOptions
  • +
  • EventLoopUtilizationMeasurementStatistics
  • +
  • IPool
  • +
  • IWorker
  • +
  • IWorkerChoiceStrategy
  • +
  • MeasurementOptions
  • +
  • MeasurementStatistics
  • +
  • MeasurementStatisticsRequirements
  • +
  • MessageValue
  • +
  • PoolInfo
  • +
  • PoolOptions
  • +
  • PromiseResponseWrapper
  • +
  • StrategyPolicy
  • +
  • Task
  • +
  • TaskError
  • +
  • TaskPerformance
  • +
  • TaskStatistics
  • +
  • TaskStatisticsRequirements
  • +
  • TasksQueueOptions
  • +
  • ThreadPoolOptions
  • +
  • WorkerChoiceStrategyOptions
  • +
  • WorkerInfo
  • +
  • WorkerNode
  • +
  • WorkerOptions
  • +
  • WorkerStatistics
  • +
  • WorkerUsage
  • +
  • ErrorHandler
  • +
  • ExitHandler
  • +
  • KillBehavior
  • +
  • Measurement
  • +
  • MessageHandler
  • +
  • OnlineHandler
  • +
  • PoolEvent
  • +
  • PoolType
  • +
  • TaskFunctions
  • +
  • WorkerAsyncFunction
  • +
  • WorkerChoiceStrategy
  • +
  • WorkerFunction
  • +
  • WorkerSyncFunction
  • +
  • WorkerType
  • +
  • KillBehaviors
  • +
  • Measurements
  • +
  • PoolEvents
  • +
  • PoolTypes
  • +
  • WorkerChoiceStrategies
  • +
  • WorkerTypes
  • +
  • availableParallelism
  • Generated using TypeDoc

    \ No newline at end of file