mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 19:00:09 +00:00
some cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5d996e5d42
commit
04a5b6a8ff
@ -712,26 +712,22 @@ function makeDeferredsQ(first){
|
|||||||
|
|
||||||
var last = first
|
var last = first
|
||||||
|
|
||||||
// this is used for two things:
|
// XXX make this a deferred-like cleanly, rather than by monkey patching...
|
||||||
// - report progress
|
var queue = $.Deferred()
|
||||||
// - 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()
|
|
||||||
|
|
||||||
// Add a worker to queue...
|
// Add a worker to queue...
|
||||||
//
|
//
|
||||||
// NOTE: .enqueue(...) accepts a worker and any number of the arguments
|
// NOTE: .enqueue(...) accepts a worker and any number of the arguments
|
||||||
// to be passed to the worker when it's its turn.
|
// to be passed to the worker when it's its turn.
|
||||||
// NOTE: the worker must porduce a deffered/promice.
|
// NOTE: the worker must porduce a deffered/promice.
|
||||||
monitor.enqueue = function(deffered){
|
queue.enqueue = function(deffered){
|
||||||
var cur = $.Deferred()
|
var cur = $.Deferred()
|
||||||
var args = Array.apply(null, arguments).slice(1)
|
var args = Array.apply(null, arguments).slice(1)
|
||||||
|
|
||||||
last.done(function(){
|
last.done(function(){
|
||||||
|
|
||||||
// see if we are killed...
|
// see if we are killed...
|
||||||
if(monitor.state() == 'resolved'){
|
if(queue.state() == 'resolved'){
|
||||||
// this will kill the queue as we continue only on success...
|
// this will kill the queue as we continue only on success...
|
||||||
cur.reject()
|
cur.reject()
|
||||||
return
|
return
|
||||||
@ -753,25 +749,28 @@ function makeDeferredsQ(first){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start the work...
|
// Start the work...
|
||||||
monitor.start = function(){
|
queue.start = function(){
|
||||||
first.resolve()
|
first.resolve()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill the queue...
|
// Kill the queue...
|
||||||
monitor.kill = function(){
|
queue.kill = function(){
|
||||||
this.resolve()
|
this.resolve()
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report work state...
|
||||||
// XXX make this a propper state, or integrate into the deferred in
|
// XXX make this a propper state, or integrate into the deferred in
|
||||||
// a more natural way...
|
// a more natural way...
|
||||||
monitor.isWorking = function(){
|
queue.isWorking = function(){
|
||||||
if(monitor.state() != 'resolved' && last.state() != 'resolved'){
|
if(queue.state() != 'resolved' && last.state() != 'resolved'){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return monitor
|
return queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user