You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
663 B
22 lines
663 B
2 years ago
|
import { WorkerChannel } from "../worker.channel";
|
||
|
import WorkerBaseController from "./worker.controller";
|
||
|
|
||
|
export class WorkerThreadController extends WorkerBaseController {
|
||
|
public constructor() {
|
||
|
super();
|
||
|
|
||
|
// Worker 线程中的全局环境 self 就是 Worker 实例
|
||
|
this.worker = self as any;
|
||
|
this.channel = new WorkerChannel(this.worker, {
|
||
|
actionHandler: this.actionHandler.bind(this),
|
||
|
});
|
||
|
}
|
||
|
|
||
|
protected reportActionHandlerError(actionType: string, error: any): void {
|
||
|
console.error(`Worker aciton ${actionType}:`, error);
|
||
|
|
||
|
// 正常抛出
|
||
|
throw new Error(error);
|
||
|
}
|
||
|
}
|