1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17import {ProcedureLogicWorkerPerf} from "./ProcedureLogicWorkerPerf.js"; 18import {ProcedureLogicWorkerNativeMemory} from "./ProcedureLogicWorkerNativeNemory.js"; 19import {ProcedureLogicWorkerFileSystem} from "./ProcedureLogicWorkerFileSystem.js"; 20import {ProcedureLogicWorkerSPT} from "./ProcedureLogicWorkerSPT.js"; 21import {ProcedureLogicWorkerCpuState} from "./ProcedureLogicWorkerCpuState.js"; 22 23 24let logicWorker: any = { 25 "perf":new ProcedureLogicWorkerPerf(), 26 "native-memory":new ProcedureLogicWorkerNativeMemory(), 27 "fileSystem":new ProcedureLogicWorkerFileSystem(), 28 "CpuState":new ProcedureLogicWorkerCpuState(), 29 "spt":new ProcedureLogicWorkerSPT(), 30} 31 32function match(req:any) { 33 Reflect.ownKeys(logicWorker).filter((it) => { 34 if (req.type && req.type.startsWith(it as string)) { 35 logicWorker[it].handle(req); 36 } 37 }) 38} 39 40self.onmessage = function (e: any) { 41 match(e.data); 42}