mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
wip : replace Job by promises
This commit is contained in:
parent
e6ed0c28a3
commit
281103c46e
@ -23,6 +23,8 @@
|
|||||||
this.cache_[namespace] = {};
|
this.cache_[namespace] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deferred = Q.defer();
|
||||||
|
|
||||||
var cache = this.cache_[namespace];
|
var cache = this.cache_[namespace];
|
||||||
|
|
||||||
var firstCacheKey = frame.getHash();
|
var firstCacheKey = frame.getHash();
|
||||||
@ -35,21 +37,20 @@
|
|||||||
processedFrame = this.outputCloner(cache[secondCacheKey], frame);
|
processedFrame = this.outputCloner(cache[secondCacheKey], frame);
|
||||||
cache[firstCacheKey] = processedFrame;
|
cache[firstCacheKey] = processedFrame;
|
||||||
} else {
|
} else {
|
||||||
var deferred = Q.defer();
|
|
||||||
this.frameProcessor(frame, this.onFrameProcessorComplete.bind(this, deferred, cache, firstCacheKey, secondCacheKey));
|
this.frameProcessor(frame, this.onFrameProcessorComplete.bind(this, deferred, cache, firstCacheKey, secondCacheKey));
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processedFrame) {
|
if (processedFrame) {
|
||||||
return Q.fcall(processedFrame);
|
deferred.resolve(processedFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.AsyncCachedFrameProcessor.prototype.onFrameProcessorComplete = function (deferred, cache, firstCacheKey, secondCacheKey, processedFrame) {
|
ns.AsyncCachedFrameProcessor.prototype.onFrameProcessorComplete = function (deferred, cache, firstCacheKey, secondCacheKey, processedFrame) {
|
||||||
cache[secondCacheKey] = processedFrame;
|
cache[secondCacheKey] = processedFrame;
|
||||||
cache[firstCacheKey] = processedFrame;
|
cache[firstCacheKey] = processedFrame;
|
||||||
console.log('RESOLVING');
|
|
||||||
deferred.resolve(processedFrame);
|
deferred.resolve(processedFrame);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
@ -58,8 +58,6 @@
|
|||||||
return this.cachedFrameProcessor.get(frame);
|
return this.cachedFrameProcessor.get(frame);
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
).done(function (results) {
|
).done(function (results) {
|
||||||
console.log('ALL DONE');
|
|
||||||
|
|
||||||
var colors = {};
|
var colors = {};
|
||||||
results.forEach(function (result) {
|
results.forEach(function (result) {
|
||||||
Object.keys(result).forEach(function (color) {
|
Object.keys(result).forEach(function (color) {
|
||||||
|
Loading…
Reference in New Issue
Block a user