wip : replace Job by promises

This commit is contained in:
Julian Descottes 2015-04-09 17:09:13 +02:00 committed by juliandescottes
parent e6ed0c28a3
commit 281103c46e
2 changed files with 5 additions and 6 deletions

View File

@ -23,6 +23,8 @@
this.cache_[namespace] = {};
}
var deferred = Q.defer();
var cache = this.cache_[namespace];
var firstCacheKey = frame.getHash();
@ -35,21 +37,20 @@
processedFrame = this.outputCloner(cache[secondCacheKey], frame);
cache[firstCacheKey] = processedFrame;
} else {
var deferred = Q.defer();
this.frameProcessor(frame, this.onFrameProcessorComplete.bind(this, deferred, cache, firstCacheKey, secondCacheKey));
return deferred.promise;
}
}
if (processedFrame) {
return Q.fcall(processedFrame);
deferred.resolve(processedFrame);
}
return deferred.promise;
};
ns.AsyncCachedFrameProcessor.prototype.onFrameProcessorComplete = function (deferred, cache, firstCacheKey, secondCacheKey, processedFrame) {
cache[secondCacheKey] = processedFrame;
cache[firstCacheKey] = processedFrame;
console.log('RESOLVING');
deferred.resolve(processedFrame);
}
})();

View File

@ -58,8 +58,6 @@
return this.cachedFrameProcessor.get(frame);
}.bind(this))
).done(function (results) {
console.log('ALL DONE');
var colors = {};
results.forEach(function (result) {
Object.keys(result).forEach(function (color) {