repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: fix dynamic import syntax
[poolifier.git]
/
src
/
worker
/
abstract-worker.ts
diff --git
a/src/worker/abstract-worker.ts
b/src/worker/abstract-worker.ts
index a84bb0691fc588d3a8e51b0fe1696d7c85bb7dc9..1e1d3088fb7cce28ad22f1961899786e6edd5fdd 100644
(file)
--- a/
src/worker/abstract-worker.ts
+++ b/
src/worker/abstract-worker.ts
@@
-45,7
+45,7
@@
export abstract class AbstractWorker<
*/
protected lastTaskTimestamp!: number
/**
*/
protected lastTaskTimestamp!: number
/**
- * Performance statistics computation.
+ * Performance statistics computation
requirements
.
*/
protected statistics!: WorkerStatistics
/**
*/
protected statistics!: WorkerStatistics
/**
@@
-160,13
+160,13
@@
export abstract class AbstractWorker<
} else if (message.parent != null) {
// Main worker reference message received
this.mainWorker = message.parent
} else if (message.parent != null) {
// Main worker reference message received
this.mainWorker = message.parent
+ } else if (message.statistics != null) {
+ // Statistics message received
+ this.statistics = message.statistics
} else if (message.kill != null) {
// Kill message received
this.aliveInterval != null && clearInterval(this.aliveInterval)
this.emitDestroy()
} else if (message.kill != null) {
// Kill message received
this.aliveInterval != null && clearInterval(this.aliveInterval)
this.emitDestroy()
- } else if (message.statistics != null) {
- // Statistics message received
- this.statistics = message.statistics
}
}
}
}
@@
-298,6
+298,7
@@
export abstract class AbstractWorker<
}
private beginTaskPerformance (): TaskPerformance {
}
private beginTaskPerformance (): TaskPerformance {
+ this.checkStatistics()
return {
timestamp: performance.now(),
...(this.statistics.elu && { elu: performance.eventLoopUtilization() })
return {
timestamp: performance.now(),
...(this.statistics.elu && { elu: performance.eventLoopUtilization() })
@@
-307,6
+308,7
@@
export abstract class AbstractWorker<
private endTaskPerformance (
taskPerformance: TaskPerformance
): TaskPerformance {
private endTaskPerformance (
taskPerformance: TaskPerformance
): TaskPerformance {
+ this.checkStatistics()
return {
...taskPerformance,
...(this.statistics.runTime && {
return {
...taskPerformance,
...(this.statistics.runTime && {
@@
-317,4
+319,10
@@
export abstract class AbstractWorker<
})
}
}
})
}
}
+
+ private checkStatistics (): void {
+ if (this.statistics == null) {
+ throw new Error('Performance statistics computation requirements not set')
+ }
+ }
}
}