|
|
@ -1,12 +1,22 @@ |
|
|
|
import { WorkerChannel } from "./worker.channel"; |
|
|
|
import { WorkerChannel } from "./worker.channel"; |
|
|
|
import { WorkerBaseController } from "./controller/worker.controller"; |
|
|
|
import { WorkerBaseController } from "./controller/worker.controller"; |
|
|
|
import { WorkerMessageType } from "./worker.core"; |
|
|
|
import { IWorkerOptions, WorkerMessageType } from "./worker.core"; |
|
|
|
import { WorkerMainThreadController } from "./controller/worker.main_thread.controller"; |
|
|
|
import { WorkerMainThreadController } from "./controller/worker.main_thread.controller"; |
|
|
|
import { WorkerThreadController } from "./controller/worker.worker_thread.controller"; |
|
|
|
import { WorkerThreadController } from "./controller/worker.worker_thread.controller"; |
|
|
|
import { WorkerBaseAction } from "./action/worker.action"; |
|
|
|
import { WorkerBaseAction } from "./action/worker.action"; |
|
|
|
import { MainThreadWorker } from "./worker.main_thread"; |
|
|
|
import { MainThreadWorker } from "./worker.main_thread"; |
|
|
|
import { WorkerThreadWorker } from "./worker.worker_thread"; |
|
|
|
import { WorkerThreadWorker } from "./worker.worker_thread"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createWorker<T extends typeof MainThreadWorker>(ThreadWorker: T, options: IWorkerOptions): InstanceType<T> |
|
|
|
|
|
|
|
function createWorker<T extends typeof WorkerThreadWorker>(ThreadWorker: T): InstanceType<T> |
|
|
|
|
|
|
|
function createWorker<T extends typeof MainThreadWorker | typeof WorkerThreadWorker>(ThreadWorker: T, options?: IWorkerOptions): InstanceType<T> { |
|
|
|
|
|
|
|
const threadWorker = new ThreadWorker(options as any) as InstanceType<T>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
threadWorker.initActions(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return threadWorker; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const Workers = { |
|
|
|
export const Workers = { |
|
|
|
WorkerChannel, |
|
|
|
WorkerChannel, |
|
|
|
WorkerBaseController, |
|
|
|
WorkerBaseController, |
|
|
@ -16,4 +26,5 @@ export const Workers = { |
|
|
|
MainThreadWorker, |
|
|
|
MainThreadWorker, |
|
|
|
WorkerThreadWorker, |
|
|
|
WorkerThreadWorker, |
|
|
|
WorkerMessageType, |
|
|
|
WorkerMessageType, |
|
|
|
|
|
|
|
createWorker, |
|
|
|
}; |
|
|
|
}; |
|
|
|