MCPcopy Index your code
hub / github.com/ampproject/amphtml / execute_

Method execute_

src/chunk.js:399–439  ·  view source on GitHub ↗

* Run a task. * Schedule the next round if there are more tasks. * @param {?IdleDeadline} idleDeadline * @return {boolean} Whether anything was executed. * @private

(idleDeadline)

Source from the content-addressed store, hash-verified

397 * @private
398 */
399 execute_(idleDeadline) {
400 const t = this.nextTask_(/* opt_dequeue */ true);
401 if (!t) {
402 this.scheduledImmediateInvocation_ = false;
403 this.durationOfLastExecution_ = 0;
404 return false;
405 }
406 let before;
407 try {
408 before = Date.now();
409 t.runTask_(idleDeadline);
410 } finally {
411 // We want to capture the time of the entire task duration including
412 // scheduled immediate (from resolved promises) micro tasks.
413 // Lacking a better way to do this we just scheduled 10 nested
414 // micro tasks.
415 resolved
416 .then()
417 .then()
418 .then()
419 .then()
420 .then()
421 .then()
422 .then()
423 .then()
424 .then(() => {
425 this.scheduledImmediateInvocation_ = false;
426 this.durationOfLastExecution_ += Date.now() - before;
427 dev().fine(
428 TAG,
429 t.getName_(),
430 'Chunk duration',
431 Date.now() - before,
432 this.durationOfLastExecution_
433 );
434
435 this.schedule_();
436 });
437 }
438 return true;
439 }
440
441 /**
442 * Calls `execute_()` asynchronously.

Callers 2

constructorMethod · 0.95
runChunksForTestingFunction · 0.45

Calls 8

nextTask_Method · 0.95
schedule_Method · 0.95
devFunction · 0.90
nowMethod · 0.80
runTask_Method · 0.80
fineMethod · 0.80
thenMethod · 0.45
getName_Method · 0.45

Tested by

no test coverage detected