worker共用同一线程方式实现

This commit is contained in:
zhouyuejun
2019-01-10 12:53:16 +08:00
parent 2da1d951ed
commit 2a2ee844c6
+17 -17
View File
@@ -470,6 +470,7 @@ export class MainComponent implements OnInit {
/**
* 创建线程并执行
*/
public promise:Worker = new Worker('/adminweb/assets/web-worker-handle.js');
creatWorkers() {
let dynamicData = {
raw_data: this.raw_data,
@@ -480,20 +481,19 @@ export class MainComponent implements OnInit {
flightStatus: this.flightStatus,
flightTypes: this.flightTypes
}
// const promise = new Worker('/assets/web-worker-handle.js');
// promise.postMessage(dynamicData);
// promise.onmessage = function (e) {
// console.log('=====');
// this.combined_data = e.data;
// this.selectChange('dynamic');
// // promise.terminate();
// }.bind(this);
const promise = this.webWorkerService.run(webWorkerHandle, dynamicData);
promise.then(function (response) {
this.combined_data = response;
this.promise.postMessage(dynamicData);
this.promise.onmessage = function (e) {
console.log('=====');
this.combined_data = e.data;
this.selectChange('dynamic');
this.webWorkerService.terminate(promise);
}.bind(this));
// this.promise.terminate();
}.bind(this);
// const promise = this.webWorkerService.run(webWorkerHandle, dynamicData);
// promise.then(function (response) {
// this.combined_data = response;
// this.selectChange('dynamic');
// this.webWorkerService.terminate(promise);
// }.bind(this));
}
/**
@@ -646,7 +646,7 @@ export class MainComponent implements OnInit {
continue;
}
} else {
if (item['preFlight'][key] === filterItems[key]) {
if (item['preFlight'][key] == filterItems[key]) {
is_satis = true;
continue;
} else {
@@ -690,7 +690,7 @@ export class MainComponent implements OnInit {
continue;
}
} else {
if (item['reaFlight'][key] === filterItems[key]) {
if (item['reaFlight'][key] == filterItems[key]) {
is_satis = true;
continue;
} else {
@@ -735,7 +735,7 @@ export class MainComponent implements OnInit {
continue;
}
} else {
if (item['preFlight'][key] === filterItems[key]) {
if (item['preFlight'][key] == filterItems[key]) {
pre_satis = true;
continue;
} else {
@@ -776,7 +776,7 @@ export class MainComponent implements OnInit {
continue;
}
} else {
if (item['reaFlight'][key] === filterItems[key]) {
if (item['reaFlight'][key] == filterItems[key]) {
rea_satis = true;
continue;
} else {