added a generic getWorkerQueue(...)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-07-14 21:04:39 +04:00
parent 3c9322a4fe
commit 0df4f139d8
3 changed files with 21 additions and 16 deletions

View File

@ -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){

View File

@ -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)

View File

@ -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