MCPcopy Create free account
hub / github.com/facebook/Rapid / _processQueue

Method _processQueue

modules/core/ValidationSystem.js:785–808  ·  view source on GitHub ↗

* _processQueue * Process the next chunk of deferred validation work * This may take time but happen in the background during browser idle time. * @param {ValidationCache} cache - The cache to process (`_head` or `_base`) * @return {Promise} Promise fulfilled when the validation has c

(cache)

Source from the content-addressed store, hash-verified

783 * @return {Promise} Promise fulfilled when the validation has completed.
784 */
785 _processQueue(cache) {
786 // console.log(`${cache.which} queue length ${cache.queue.length}`);
787
788 if (!cache.queue.length) return Promise.resolve(); // we're done
789 const chunk = cache.queue.pop();
790
791 return new Promise((resolve, reject) => {
792 const handle = window.requestIdleCallback(() => {
793 this._deferredRIC.delete(handle);
794 // const t0 = performance.now();
795 chunk.forEach(job => job());
796 // const t1 = performance.now();
797 // console.log('chunk processed in ' + (t1 - t0) + ' ms');
798 resolve();
799 });
800 this._deferredRIC.set(handle, reject);
801 })
802 .then(() => { // dispatch an event sometimes to redraw various UI things
803 if (cache.queue.length % 100 === 0) {
804 this.emit('validated');
805 }
806 })
807 .then(() => this._processQueue(cache));
808 }
809}
810
811

Callers 1

Calls 1

resolveFunction · 0.50

Tested by

no test coverage detected