// eslint-disable-next-line n/no-process-exit
process.exit()
}
-;(async () => {
+(async () => {
try {
await run()
} catch (e) {
// eslint-disable-next-line n/no-process-exit
process.exit()
}
-;(async () => {
+(async () => {
try {
await run()
} catch (e) {
import { dirname, extname, join } from 'path'
import { fileURLToPath } from 'url'
-import type { MyData, MyResponse } from './worker'
import {
DynamicThreadPool,
FixedThreadPool,
availableParallelism
} from 'poolifier'
+import type { MyData, MyResponse } from './worker'
const workerFile = join(
dirname(fileURLToPath(import.meta.url)),
message: MessageValue<Data>,
transferList?: TransferListItem[]
): void {
- ;(
+ (
this.workerNodes[workerNodeKey].messageChannel as MessageChannel
).port1.postMessage(message, transferList)
}
workerNodeKey: number,
listener: (message: MessageValue<Message>) => void
): void {
- ;(
+ (
this.workerNodes[workerNodeKey].messageChannel as MessageChannel
).port1.on('message', listener)
}
this.onEmptyQueueCount = 0
return
}
- ;(this.onEmptyQueue as WorkerNodeEventCallback)(this.info.id as number)
+ (this.onEmptyQueue as WorkerNodeEventCallback)(this.info.id as number)
++this.onEmptyQueueCount
await sleep(exponentialDelay(this.onEmptyQueueCount))
await this.startOnEmptyQueue()
protected handleKillMessage (message: MessageValue<Data>): void {
this.stopCheckActive()
if (isAsyncFunction(this.opts.killHandler)) {
- ;(this.opts.killHandler?.() as Promise<void>)
+ (this.opts.killHandler?.() as Promise<void>)
.then(() => {
this.sendToMainWorker({ kill: 'success', workerId: this.id })
return null