Permalink
Browse files

downloader works again

  • Loading branch information...
1 parent fbc1504 commit f2fce203d4d089bac1d13fd4677ee8ee20ac7772 @coolaj86 coolaj86 committed Apr 14, 2012
Showing with 10 additions and 4 deletions.
  1. +10 −4 example/downloader.js
View
14 example/downloader.js
@@ -38,10 +38,6 @@
}
join = Join();
-
- sequences.forEach(function (seq) {
- seq.then(join.add());
- });
}
, add: function (fn) {
mod = (mod % sequences.length);
@@ -51,6 +47,13 @@
, when: function (cb) {
join.when(cb);
}
+ , start: function () {
+ process.nextTick(function () {
+ sequences.forEach(function (seq) {
+ seq.then(join.add());
+ });
+ });
+ }
};
parallel.setThreads(nThreads);
@@ -76,6 +79,7 @@
// prototype-itize and subclass as EventEmitter
function download(callback, tiles, strategy) {
var emitter = new EventEmitter()
+ , maxThreads = 4
, parallel = Parallel(maxThreads)
;
@@ -133,9 +137,11 @@
fs.lstat(newfilepath, function (err, stat) {
if (!stat) {
+ sys.print('.');
emitter.emit('cache-miss', tile, url);
getTile();
} else {
+ sys.print('+');
emitter.emit('cache-hit', tile, url);
next();
}

0 comments on commit f2fce20

Please sign in to comment.