私は、Web ブラウザーで実行される Javascript シミュレーターに取り組んでいます。メインループがあります:
do {
updateVisualization(simulator);
simulator.doStep();
} while (!reachedGoal(simulator));
そして、反復ごとに、同時に実行する必要がある複数のワーカーを実行する必要があります。
doStep = function() {
...
for (every agent in the simulation) {
var worker = new Worker('worker.js');
worker.onmessage = function(event) {
...
}
worker.postMessage(...);
}
// Here is the problem
}
私の質問は、すべてのワーカーが終了するのをどのように待つことができるでしょうか?