From dc178652a8f5c5e343f11b9800617e8581a4c586 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 23 Jan 2014 07:04:17 +0400 Subject: [PATCH] some cleanup and minor tweaking... Signed-off-by: Alex A. Naanou --- ui/workers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/workers.js b/ui/workers.js index e6ac6a99..91fff046 100755 --- a/ui/workers.js +++ b/ui/workers.js @@ -82,11 +82,18 @@ function getWorkerQueue(name, pool_size, no_auto_start, no_progress){ // Kill all worker queues... // -// Returns a deffered object that will get resolved when all workers are +// Returns a deffered that will get resolved when all workers are // actually stopped... +// +// NOTE: this will not stop the already started tasks, just drop all +// worker queues, thus it may take some time for workers to +// actually stop... +// NOTE: if no workers are loaded or all are already done, the deferred +// returned will be resolved... function killAllWorkers(){ var res = $.Deferred() var w = [] + Object.keys(WORKERS).forEach(function(k){ if(WORKERS[k].isRunning()){ var wd = $.Deferred() @@ -102,6 +109,7 @@ function killAllWorkers(){ }) WORKERS = {} + // resolve the deferred as soon as ALL the workers are done... $.when.apply(null, w) .done(function(){ console.log('Worker: All workers stopped.')