*
* @param task - The task to execute.
*/
- protected run (task: Task<Data>): void {
+ protected readonly run = (task: Task<Data>): void => {
const { name, taskId, data } = task
const taskFunctionName = name ?? DEFAULT_TASK_NAME
if (!this.taskFunctions.has(taskFunctionName)) {
* @param fn - Task function that will be executed.
* @param task - Input data for the task function.
*/
- protected runSync (
+ protected readonly runSync = (
fn: TaskSyncFunction<Data, Response>,
task: Task<Data>
- ): void {
+ ): void => {
const { name, taskId, data } = task
try {
let taskPerformance = this.beginTaskPerformance(name)
* @param fn - Task function that will be executed.
* @param task - Input data for the task function.
*/
- protected runAsync (
+ protected readonly runAsync = (
fn: TaskAsyncFunction<Data, Response>,
task: Task<Data>
- ): void {
+ ): void => {
const { name, taskId, data } = task
let taskPerformance = this.beginTaskPerformance(name)
fn(data)
}
/** @inheritDoc */
- protected sendToMainWorker (message: MessageValue<Response>): void {
+ protected readonly sendToMainWorker = (
+ message: MessageValue<Response>
+ ): void => {
this.getMainWorker().send({ ...message, workerId: this.id })
}
}
}
/** @inheritDoc */
- protected sendToMainWorker (message: MessageValue<Response>): void {
+ protected readonly sendToMainWorker = (
+ message: MessageValue<Response>
+ ): void => {
this.port?.postMessage({ ...message, workerId: this.id })
}