From 0df4f139d8631895d163c83b018ac6751c0da759 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 14 Jul 2013 21:04:39 +0400 Subject: [PATCH] added a generic getWorkerQueue(...)... Signed-off-by: Alex A. Naanou --- ui/compatibility.js | 8 +------- ui/data.js | 19 +++++++++++++++++++ ui/files.js | 10 +--------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ui/compatibility.js b/ui/compatibility.js index 15c1de91..e2ea7c6b 100755 --- a/ui/compatibility.js +++ b/ui/compatibility.js @@ -361,13 +361,7 @@ if(window.CEF_dumpJSON != null){ window.makeImagesPreviewsQ = function(gids, sizes, mode){ gids = gids == null ? getClosestGIDs() : gids - // attach the the previous queue... - if(WORKERS.preview_generator == null){ - var queue = makeDeferredsQ() - WORKERS.preview_generator = queue.start() - } else { - var queue = WORKERS.preview_generator - } + var queue = getWorkerQueue('preview_generator') // attach the workers to the queue... $.each(gids, function(_, gid){ diff --git a/ui/data.js b/ui/data.js index a72222df..5176c180 100755 --- a/ui/data.js +++ b/ui/data.js @@ -1179,6 +1179,25 @@ function getPrevLocation(){ /********************************************************* Workers ***/ +// get/create a named worker queue... +// +function getWorkerQueue(name, no_auto_start){ + // attach the the previous queue... + if(WORKERS[name] == null){ + var queue = makeDeferredsQ() + WORKERS[name] = queue + if(!no_auto_start){ + queue.start() + } + } else { + var queue = WORKERS[name] + } + return queue +} + + +// kill all worker queues... +// function killAllWorkers(){ for(var k in WORKERS){ console.log('Worker: Stopping:', k) diff --git a/ui/files.js b/ui/files.js index 0afbcaaf..167fd5ee 100755 --- a/ui/files.js +++ b/ui/files.js @@ -717,18 +717,10 @@ function updateImagesOrientation(gids, no_update_loaded){ // queued version of updateImagesOrientation(...) // -// XXX do we need to auto-stop this??? function updateImagesOrientationQ(gids, no_update_loaded){ gids = gids == null ? getClosestGIDs() : gids - //var queue = makeDeferredsQ().start() - // attach the the previous queue... - if(WORKERS.image_orientation_reader == null){ - var queue = makeDeferredsQ() - WORKERS.image_orientation_reader = queue.start() - } else { - var queue = WORKERS.image_orientation_reader - } + var queue = getWorkerQueue('image_orientation_reader') var last = null