Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
workerNodeTasksUsage.sequentiallyStolen === 0
) {
workerNode.emit('idle', {
workerNodeTasksUsage.sequentiallyStolen === 0
) {
workerNode.emit('idle', {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- workerId: workerId!,
this.workerNodeVirtualTaskRunTime = 0
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.workerNodeVirtualTaskRunTime = 0
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const workerWeight = this.opts!.weights![workerNodeKey]!
+ const workerWeight = this.opts!.weights![workerNodeKey]
if (
this.isWorkerNodeReady(workerNodeKey) &&
workerWeight >= this.roundWeights[roundIndex] &&
if (
this.isWorkerNodeReady(workerNodeKey) &&
workerWeight >= this.roundWeights[roundIndex] &&
type TransferListItem,
type Worker,
isMainThread
type TransferListItem,
type Worker,
isMainThread
protected sendStartupMessageToWorker (workerNodeKey: number): void {
const workerNode = this.workerNodes[workerNodeKey]
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
protected sendStartupMessageToWorker (workerNodeKey: number): void {
const workerNode = this.workerNodes[workerNodeKey]
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- const port2: MessagePort = workerNode.messageChannel!.port2
+ const port2 = workerNode.messageChannel!.port2
workerNode.worker.postMessage(
{
ready: false,
workerNode.worker.postMessage(
{
ready: false,
const tasksQueueSize = this.tasksQueue.push(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true
const tasksQueueSize = this.tasksQueue.push(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.emit('backPressure', { workerId: this.info.id! })
+ this.emit('backPressure', { workerId: this.info.id })
this.onBackPressureStarted = false
}
return tasksQueueSize
this.onBackPressureStarted = false
}
return tasksQueueSize
const tasksQueueSize = this.tasksQueue.unshift(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true
const tasksQueueSize = this.tasksQueue.unshift(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- this.emit('backPressure', { workerId: this.info.id! })
+ this.emit('backPressure', { workerId: this.info.id })
this.onBackPressureStarted = false
}
return tasksQueueSize
this.onBackPressureStarted = false
}
return tasksQueueSize
message: MessageValue<Data>
): void {
const { taskFunctionOperation, taskFunctionName, taskFunction } = message
message: MessageValue<Data>
): void {
const { taskFunctionOperation, taskFunctionName, taskFunction } = message
- let response!: TaskFunctionOperationResult
+ if (taskFunctionName == null) {
+ throw new Error(
+ 'Cannot handle task function operation message without a task function name'
+ )
+ }
+ let response: TaskFunctionOperationResult
switch (taskFunctionOperation) {
case 'add':
response = this.addTaskFunction(
switch (taskFunctionOperation) {
case 'add':
response = this.addTaskFunction(
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- taskFunctionName!,
- // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func, @typescript-eslint/no-non-null-assertion
- new Function(`return ${taskFunction!}`)() as TaskFunction<
+ taskFunctionName,
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
+ new Function(`return ${taskFunction}`)() as TaskFunction<
Data,
Response
>
)
break
case 'remove':
Data,
Response
>
)
break
case 'remove':
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- response = this.removeTaskFunction(taskFunctionName!)
+ response = this.removeTaskFunction(taskFunctionName)
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- response = this.setDefaultTaskFunction(taskFunctionName!)
+ response = this.setDefaultTaskFunction(taskFunctionName)
break
default:
response = { status: false, error: new Error('Unknown task operation') }
break
default:
response = { status: false, error: new Error('Unknown task operation') }
...(!response.status &&
response.error != null && {
workerError: {
...(!response.status &&
response.error != null && {
workerError: {
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- name: taskFunctionName!,
+ name: taskFunctionName,
message: this.handleError(response.error as Error | string)
}
})
message: this.handleError(response.error as Error | string)
}
})