mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
fixed a couple of bugs + added a 'filling' state to deferred pool (jli)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6bc0f8785e
commit
e70a45d5b2
11
ui/TODO.otl
11
ui/TODO.otl
@ -562,6 +562,17 @@ Roadmap
|
|||||||
| drops to last placeholder
|
| drops to last placeholder
|
||||||
|
|
|
|
||||||
[_] single image mode transition (alpha-blend/fade/none)
|
[_] single image mode transition (alpha-blend/fade/none)
|
||||||
|
[X] BUG: deferredPool breaks on exporting previews and a preview exists...
|
||||||
|
| export in place (default settings) runs through an initial set of
|
||||||
|
| workers and stops in an odd state:
|
||||||
|
| - pool is full
|
||||||
|
| - al workers resolved
|
||||||
|
|
|
||||||
|
| this appears to be the result of exportImageTo(..) not overwriting
|
||||||
|
| a preview...
|
||||||
|
[X] BUG: export: if lots of images already exist, the pool triggers depleted early...
|
||||||
|
| this happens if we are clearing the pool out faster than adding
|
||||||
|
| new tasks to queue...
|
||||||
[X] buildcache: add ability to process multiple dirs...
|
[X] buildcache: add ability to process multiple dirs...
|
||||||
[X] BUG: progress bars do not handle errors...
|
[X] BUG: progress bars do not handle errors...
|
||||||
[X] BUG: sorting (dialog) will mess up the order...
|
[X] BUG: sorting (dialog) will mess up the order...
|
||||||
|
|||||||
@ -987,7 +987,6 @@ function exportImageTo(gid, path, im_name, size){
|
|||||||
dest = path +'/'+ dest
|
dest = path +'/'+ dest
|
||||||
|
|
||||||
// copy...
|
// copy...
|
||||||
// NOTE: the sad smily face here is here for JS compatibility ;)
|
|
||||||
return (function(src, dest){
|
return (function(src, dest){
|
||||||
return copyFile(src, dest)
|
return copyFile(src, dest)
|
||||||
.done(function(){
|
.done(function(){
|
||||||
@ -1038,6 +1037,8 @@ function exportImagesTo(path, im_name, dir_name, size){
|
|||||||
res.resolve()
|
res.resolve()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
pool.filling()
|
||||||
|
|
||||||
// go through ribbons...
|
// go through ribbons...
|
||||||
for(var i=DATA.ribbons.length-1; i >= 0; i--){
|
for(var i=DATA.ribbons.length-1; i >= 0; i--){
|
||||||
var ribbon = DATA.ribbons[i]
|
var ribbon = DATA.ribbons[i]
|
||||||
@ -1060,6 +1061,8 @@ function exportImagesTo(path, im_name, dir_name, size){
|
|||||||
path = normalizePath(path +'/'+ dir_name)
|
path = normalizePath(path +'/'+ dir_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pool.doneFilling()
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -668,6 +668,19 @@ jQuery.fn.sortChildren = function(func){
|
|||||||
//
|
//
|
||||||
// This will create and return a pooled queue of deferred workers.
|
// This will create and return a pooled queue of deferred workers.
|
||||||
//
|
//
|
||||||
|
//
|
||||||
|
// The pool can be in one of the folowing states:
|
||||||
|
//
|
||||||
|
// - filling
|
||||||
|
// This state prevents .depleted() from triggering until the pool
|
||||||
|
// exits the filling state.
|
||||||
|
// This helps us to prevent premature depletion of the pool in
|
||||||
|
// cases where the queue is depleted faster than it is being filled.
|
||||||
|
//
|
||||||
|
// - paused
|
||||||
|
// This state prevents any new queued workers from starting.
|
||||||
|
//
|
||||||
|
//
|
||||||
// Public interface:
|
// Public interface:
|
||||||
//
|
//
|
||||||
// .enqueue(obj, func, args) -> deferred
|
// .enqueue(obj, func, args) -> deferred
|
||||||
@ -677,6 +690,20 @@ jQuery.fn.sortChildren = function(func){
|
|||||||
// If the pool is full the worker is added to queue (FIFO) and
|
// If the pool is full the worker is added to queue (FIFO) and
|
||||||
// ran in its turn.
|
// ran in its turn.
|
||||||
//
|
//
|
||||||
|
// .dropQueue() -> pool
|
||||||
|
// Drop the queued workers.
|
||||||
|
// NOTE: this will not stop the already running workers.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// .filling()
|
||||||
|
// Enter the filling state
|
||||||
|
//
|
||||||
|
// .doneFilling()
|
||||||
|
// Exit the filling state
|
||||||
|
// NOTE: this will trigger .depleted() if at the time of call
|
||||||
|
// both the pool and queue are empty.
|
||||||
|
//
|
||||||
|
//
|
||||||
// .pause() -> pool
|
// .pause() -> pool
|
||||||
// Pause the queue.
|
// Pause the queue.
|
||||||
// NOTE: this also has a second form: .pause(func), see below.
|
// NOTE: this also has a second form: .pause(func), see below.
|
||||||
@ -684,9 +711,9 @@ jQuery.fn.sortChildren = function(func){
|
|||||||
// .resume() -> pool
|
// .resume() -> pool
|
||||||
// Restart the queue.
|
// Restart the queue.
|
||||||
//
|
//
|
||||||
// .dropQueue() -> pool
|
//
|
||||||
// Drop the queued workers.
|
// .isFilling() -> bool
|
||||||
// NOTE: this will not stop the already running workers.
|
// Test if the pool is being filled -- filling state.
|
||||||
//
|
//
|
||||||
// .isRunning() -> bool
|
// .isRunning() -> bool
|
||||||
// Test if any workers are running in the pool.
|
// Test if any workers are running in the pool.
|
||||||
@ -792,9 +819,15 @@ function makeDeferredPool(size, paused){
|
|||||||
|
|
||||||
// run an element from the queue...
|
// run an element from the queue...
|
||||||
var worker = func.apply(null, args)
|
var worker = func.apply(null, args)
|
||||||
|
pool.push(worker)
|
||||||
|
|
||||||
|
// NOTE: this is explicitly after the pool push to avoid the
|
||||||
|
// possible race condition of the worker exiting and
|
||||||
|
// triggering .always(..) before being added to the pool...
|
||||||
|
worker
|
||||||
.always(function(){
|
.always(function(){
|
||||||
// prepare to remove self from pool...
|
// prepare to remove self from pool...
|
||||||
var i = pool.indexOf(worker)
|
var i = pool.indexOf(this)
|
||||||
|
|
||||||
Pool._event_handlers.progress.fire(pool.length - pool.len(), pool.length + queue.length)
|
Pool._event_handlers.progress.fire(pool.length - pool.len(), pool.length + queue.length)
|
||||||
|
|
||||||
@ -830,7 +863,9 @@ function makeDeferredPool(size, paused){
|
|||||||
// pushed to pool just before it's "compacted"...
|
// pushed to pool just before it's "compacted"...
|
||||||
pool.length = 0
|
pool.length = 0
|
||||||
|
|
||||||
that._event_handlers.deplete.fire(l)
|
if(!that._filling){
|
||||||
|
that._event_handlers.deplete.fire(l)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep the pool full...
|
// keep the pool full...
|
||||||
@ -847,8 +882,6 @@ function makeDeferredPool(size, paused){
|
|||||||
deferred.resolve.apply(deferred, arguments)
|
deferred.resolve.apply(deferred, arguments)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.pool.push(worker)
|
|
||||||
|
|
||||||
return worker
|
return worker
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,6 +932,31 @@ function makeDeferredPool(size, paused){
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filling state...
|
||||||
|
//
|
||||||
|
// When this mode is set, it will prevent the queue from triggering
|
||||||
|
// the depleated action until .doneFilling() is called...
|
||||||
|
//
|
||||||
|
// This is to prevent the pool depleting before the queue is filled
|
||||||
|
// in the case of tasks ending faster than they are added...
|
||||||
|
Pool.filling = function(){
|
||||||
|
this._filling = true
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
Pool.doneFilling = function(){
|
||||||
|
delete this._filling
|
||||||
|
// trigger depleted if we are empty...
|
||||||
|
if(this.pool.len() == 0 && this.queue.length == 0){
|
||||||
|
that._event_handlers.deplete.fire(l)
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
Pool.isFilling = function(){
|
||||||
|
return this._filling == true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paused state...
|
||||||
|
//
|
||||||
// NOTE: this will not directly cause .isRunning() to return false
|
// NOTE: this will not directly cause .isRunning() to return false
|
||||||
// as this will not directly spot all workers, it will just
|
// as this will not directly spot all workers, it will just
|
||||||
// pause the queue and the workers that have already started
|
// pause the queue and the workers that have already started
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user