* The pool automatically checks and terminates this worker when the time expires.
*/
maxInactiveTime: DEFAULT_MAX_INACTIVE_TIME
* The pool automatically checks and terminates this worker when the time expires.
*/
maxInactiveTime: DEFAULT_MAX_INACTIVE_TIME
*/
protected messageListener (message: MessageValue<Data, Data>): void {
if (message.workerId === this.id) {
if (message.ready != null) {
// Startup message received
*/
protected messageListener (message: MessageValue<Data, Data>): void {
if (message.workerId === this.id) {
if (message.ready != null) {
// Startup message received
} else if (message.statistics != null) {
// Statistics message received
this.statistics = message.statistics
} else if (message.statistics != null) {
// Statistics message received
this.statistics = message.statistics
- } else if (message.checkAlive != null) {
- // Check alive message received
- message.checkAlive ? this.startCheckAlive() : this.stopCheckAlive()
+ } else if (message.checkActive != null) {
+ // Check active message received
+ message.checkActive ? this.startCheckActive() : this.stopCheckActive()
- this.aliveInterval = setInterval(
- this.checkAlive.bind(this),
+ this.activeInterval = setInterval(
+ this.checkActive.bind(this),
- private stopCheckAlive (): void {
- this.aliveInterval != null && clearInterval(this.aliveInterval)
+ private stopCheckActive (): void {
+ this.activeInterval != null && clearInterval(this.activeInterval)
if (
performance.now() - this.lastTaskTimestamp >
(this.opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME)
if (
performance.now() - this.lastTaskTimestamp >
(this.opts.maxInactiveTime ?? DEFAULT_MAX_INACTIVE_TIME)