repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps): bump poolifier
[poolifier.git]
/
src
/
worker
/
cluster-worker.ts
diff --git
a/src/worker/cluster-worker.ts
b/src/worker/cluster-worker.ts
index c820641ddbb10319b454bf5b25154312703cc446..08eb4e89c81e18e33d02ebae675395e3fe8b33d6 100644
(file)
--- a/
src/worker/cluster-worker.ts
+++ b/
src/worker/cluster-worker.ts
@@
-2,7
+2,7
@@
import cluster, { type Worker } from 'node:cluster'
import type { MessageValue } from '../utility-types'
import { AbstractWorker } from './abstract-worker'
import type { WorkerOptions } from './worker-options'
import type { MessageValue } from '../utility-types'
import { AbstractWorker } from './abstract-worker'
import type { WorkerOptions } from './worker-options'
-import type { TaskFunction
s, WorkerFunction } from './worker
-functions'
+import type { TaskFunction
, TaskFunctions } from './task
-functions'
/**
* A cluster worker used by a poolifier `ClusterPool`.
/**
* A cluster worker used by a poolifier `ClusterPool`.
@@
-29,9
+29,7
@@
export class ClusterWorker<
* @param opts - Options for the worker.
*/
public constructor (
* @param opts - Options for the worker.
*/
public constructor (
- taskFunctions:
- | WorkerFunction<Data, Response>
- | TaskFunctions<Data, Response>,
+ taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>,
opts: WorkerOptions = {}
) {
super(
opts: WorkerOptions = {}
) {
super(
@@
-41,15
+39,13
@@
export class ClusterWorker<
taskFunctions,
opts
)
taskFunctions,
opts
)
- if (!this.isMain) {
- this.getMainWorker()?.on('message', this.messageListener.bind(this))
- }
}
/** @inheritDoc */
protected handleReadyMessage (message: MessageValue<Data>): void {
if (message.workerId === this.id && message.ready != null) {
}
/** @inheritDoc */
protected handleReadyMessage (message: MessageValue<Data>): void {
if (message.workerId === this.id && message.ready != null) {
- !this.isMain && this.sendToMainWorker({ ready: true, workerId: this.id })
+ this.getMainWorker()?.on('message', this.messageListener.bind(this))
+ this.sendToMainWorker({ ready: true, workerId: this.id })
}
}
}
}