mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-18 01:01:40 +00:00
added pooling to export (files.js)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5d3a50cb15
commit
e79e42fe40
55
ui/files.js
55
ui/files.js
@ -843,8 +843,6 @@ function exportImagesTo(path, im_name, dir_name, size){
|
|||||||
var z = (('10e' + (selection.length + '').length) * 1 + '').slice(2)
|
var z = (('10e' + (selection.length + '').length) * 1 + '').slice(2)
|
||||||
|
|
||||||
var queue = []
|
var queue = []
|
||||||
var pool = []
|
|
||||||
var pool_size = 10
|
|
||||||
|
|
||||||
// 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--){
|
||||||
@ -868,10 +866,61 @@ function exportImagesTo(path, im_name, dir_name, size){
|
|||||||
path = normalizePath(path +'/'+ dir_name)
|
path = normalizePath(path +'/'+ dir_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
var res = []
|
||||||
// XXX pool this...
|
// XXX pool this...
|
||||||
queue.forEach(function(e){
|
queue.forEach(function(e){
|
||||||
exportImageTo.apply(null, e)
|
res.push(exportImageTo.apply(null, e))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return $.when.apply(null, res)
|
||||||
|
.done(function(){
|
||||||
|
showStatusQ('Export: done.')
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
// XXX make this generic...
|
||||||
|
var pool = []
|
||||||
|
var pool_size = 100
|
||||||
|
var res = $.Deferred()
|
||||||
|
|
||||||
|
var enqueue = function(e){
|
||||||
|
if(e == null){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var worker = exportImageTo.apply(null, e)
|
||||||
|
.done(function(){
|
||||||
|
// remove self from pool...
|
||||||
|
var i = pool.indexOf(worker)
|
||||||
|
|
||||||
|
// get the next queue item...
|
||||||
|
var next = queue.splice(0, 1)[0]
|
||||||
|
|
||||||
|
// enqueue the next worker if it exists...
|
||||||
|
if(next != null){
|
||||||
|
pool[i] = enqueue(next)
|
||||||
|
|
||||||
|
// nothing in queue...
|
||||||
|
} else {
|
||||||
|
// remove self...
|
||||||
|
pool.splice(i, 1)
|
||||||
|
|
||||||
|
// empty queue and empty pool mean we are done...
|
||||||
|
if(pool.length == 0){
|
||||||
|
showStatusQ('Export: done.')
|
||||||
|
res.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail(function(){
|
||||||
|
var i = pool.indexOf(worker)
|
||||||
|
// remove self...
|
||||||
|
pool.splice(i, 1)
|
||||||
|
})
|
||||||
|
return worker
|
||||||
|
}
|
||||||
|
pool = queue.splice(0, pool_size).map(enqueue)
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user