fineui是帆软报表和BI产品线所使用的前端框架。
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.

52 lines
1.2 KiB

import type { WorkerBaseAction } from "./action/worker.action";
import { WorkerMainThreadController } from "./controller/worker.main_thread.controller";
import { IWorkerOptions } from "./worker.core";
/**
* 线Worker
*/
export class MainThreadWorker {
/**
* Worker
*/
public name: string;
/**
* 线
*/
public controller: WorkerMainThreadController;
/**
* Worker
*/
protected isTerminated = false;
public constructor(options: IWorkerOptions) {
this.name = options.workerName;
this.controller = new WorkerMainThreadController(options);
}
/**
* actions
*/
public initActions() {}
/**
* worker
* action
*/
public terminate(): void {
this.controller.terminate();
// 设置终止标志位
this.isTerminated = true;
}
/**
* action
* @param Action action类
*/
protected createAction<T extends typeof WorkerBaseAction>(Action: T): InstanceType<T> {
return (new Action(this.controller, this)) as InstanceType<T>;
}
}