mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-26 13:01:58 +00:00
added a generic deffered queue...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9c5b61ef22
commit
74876cf255
10
ui/files.js
10
ui/files.js
@ -716,13 +716,14 @@ function updateImagesOrientation(gids, no_update_loaded){
|
|||||||
//
|
//
|
||||||
function updateImagesOrientationQ(gids, no_update_loaded){
|
function updateImagesOrientationQ(gids, no_update_loaded){
|
||||||
gids = gids == null ? getClosestGIDs() : gids
|
gids = gids == null ? getClosestGIDs() : gids
|
||||||
//var res = []
|
|
||||||
|
|
||||||
var last = $.Deferred().resolve()
|
var last = $.Deferred().resolve()
|
||||||
|
|
||||||
// this is used for two things:
|
// this is used for two things:
|
||||||
// - report progress
|
// - report progress
|
||||||
// - kill the queue if needed...
|
// - kill the queue if needed...
|
||||||
|
// XXX make this a deferred-like cleanly rather than bu monkey patching...
|
||||||
|
// XXX do we need to make this resumable??
|
||||||
var monitor = $.Deferred()
|
var monitor = $.Deferred()
|
||||||
monitor.killed = false
|
monitor.killed = false
|
||||||
monitor.kill = function(){
|
monitor.kill = function(){
|
||||||
@ -732,12 +733,15 @@ function updateImagesOrientationQ(gids, no_update_loaded){
|
|||||||
$.each(gids, function(_, gid){
|
$.each(gids, function(_, gid){
|
||||||
var cur = $.Deferred()
|
var cur = $.Deferred()
|
||||||
last.done(function(){
|
last.done(function(){
|
||||||
|
// see if we are killed...
|
||||||
if(monitor.killed == true){
|
if(monitor.killed == true){
|
||||||
monitor.notify('killed')
|
monitor.notify('killed')
|
||||||
monitor.resolve()
|
monitor.resolve()
|
||||||
|
// this will kill the queue as we continue only on success...
|
||||||
cur.reject()
|
cur.reject()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// do the work...
|
||||||
updateImageOrientation(gid, no_update_loaded)
|
updateImageOrientation(gid, no_update_loaded)
|
||||||
.done(function(o){
|
.done(function(o){
|
||||||
cur.resolve(o)
|
cur.resolve(o)
|
||||||
@ -750,12 +754,8 @@ function updateImagesOrientationQ(gids, no_update_loaded){
|
|||||||
})
|
})
|
||||||
|
|
||||||
last = cur
|
last = cur
|
||||||
//res.push(cur)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// NOTE: .when(...) is used to add more introspecitve feedback...
|
|
||||||
//return $.when.apply(null, res)
|
|
||||||
// return last
|
|
||||||
last.done(function(){
|
last.done(function(){
|
||||||
monitor.resolve()
|
monitor.resolve()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -678,23 +678,54 @@ function assyncCall(func){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
function makeDeferredsQ(){
|
||||||
function chainDeferreds(deferred, after){
|
|
||||||
after = after == null ? $.Deferred.resolve() : after
|
|
||||||
|
|
||||||
$.each(deferred, function(_, d){
|
var first = $.Deferred().resolve()
|
||||||
|
var last = first
|
||||||
|
|
||||||
|
// this is used for two things:
|
||||||
|
// - report progress
|
||||||
|
// - kill the queue if needed...
|
||||||
|
// XXX make this a deferred-like cleanly rather than bu monkey patching...
|
||||||
|
// XXX do we need to make this resumable??
|
||||||
|
var monitor = $.Deferred()
|
||||||
|
|
||||||
|
monitor.kill = function(){
|
||||||
|
this.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor.enqueue = function(deffered){
|
||||||
var cur = $.Deferred()
|
var cur = $.Deferred()
|
||||||
after.done(function(){
|
last.done(function(){
|
||||||
d()
|
|
||||||
.done(function(){ cur.resolve() })
|
|
||||||
.fail(function(){ cur.reject() })
|
|
||||||
})
|
|
||||||
after = cur
|
|
||||||
})
|
|
||||||
|
|
||||||
return after
|
// see if we are killed...
|
||||||
|
if(monitor.state() == 'resolved'){
|
||||||
|
// this will kill the queue as we continue only on success...
|
||||||
|
cur.reject()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// do the work...
|
||||||
|
deffered.apply(null, Array.apply(null, arguments).slice(1))
|
||||||
|
.done(function(o){
|
||||||
|
cur.resolve(o)
|
||||||
|
monitor.notify('done')
|
||||||
|
})
|
||||||
|
.fail(function(){
|
||||||
|
cur.resolve('fail')
|
||||||
|
monitor.notify('fail')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
last = cur
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor.start = function(){
|
||||||
|
first.resolve()
|
||||||
|
}
|
||||||
|
|
||||||
|
return monitor
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user