Skip to content

editorGlobalsWorkerPool

Class: WorkerPool

This class manages a pool of workers per worker js file. Workers that are managed by this WorkerPool need to adhere to the following simple interface: - When a worker has finished a job, it sends a message with the

Hierarchy

  • WorkerPool

Index

Properties

Methods

Properties

Static Private Readonly pools

pools: Map‹WorkerBuilder, Pool = new Map()

Defined in src/worker/WorkerPool.ts:58

Methods

Static Private _cancelJob

_cancelJob(jobId: number, pool: Pool): void

Defined in src/worker/WorkerPool.ts:105

Parameters:

Name Type
jobId number
pool Pool

Returns: void


Static Private _enqueue

_enqueue(job: Job, pool: Pool, transferables: Transferable[]): ICancellablePromise‹any›

Defined in src/worker/WorkerPool.ts:87

Parameters:

Name Type
job Job
pool Pool
transferables Transferable[]

Returns: ICancellablePromise‹any›


Static Private _getNextJobId

_getNextJobId(): number

Defined in src/worker/WorkerPool.ts:82

Returns: number


Static Private _getPool

_getPool(workerBuilder: WorkerBuilder): Pool

Defined in src/worker/WorkerPool.ts:212

Parameters:

Name Type
workerBuilder WorkerBuilder

Returns: Pool


Static Private _instantiateWorker

_instantiateWorker(pool: Pool): void

Defined in src/worker/WorkerPool.ts:192

Parameters:

Name Type
pool Pool

Returns: void


Static Private _onMessage

_onMessage(message: IMessage): void

Defined in src/worker/WorkerPool.ts:124

Parameters:

Name Type
message IMessage

Returns: void


Static Private _startNextJob

_startNextJob(pool: Pool): void

Defined in src/worker/WorkerPool.ts:163

Parameters:

Name Type
pool Pool

Returns: void


Static Private _terminateWorker

_terminateWorker(worker: KyubWorker): void

Defined in src/worker/WorkerPool.ts:200

Parameters:

Name Type
worker KyubWorker

Returns: void


Static cancelAllRunningJobs

cancelAllRunningJobs(): void

Defined in src/worker/WorkerPool.ts:78

Returns: void


Static postJob

postJob(workerBuilder: WorkerBuilder, job: Job, transferables: Transferable[]): ICancellablePromise‹any›

Defined in src/worker/WorkerPool.ts:69

Post the job to one of the workers running the JS file identified by workerJsFileName

Parameters:

Name Type Description
workerBuilder WorkerBuilder -
job Job Job the worker is supposed to run, this is passed to the worker as message.data.job
transferables Transferable[] Transferables that will be "transferred" to the worker, if possible https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage

Returns: ICancellablePromise‹any›

a promise that resolves to the job result. The Promise has an extra function property cancel. Calling this function causes the job to be cancelled. It will then neither reject nor resolve.