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

Method schedule_

src/chunk.js:473–504  ·  view source on GitHub ↗

* Schedule running the next queued task. * @private

()

Source from the content-addressed store, hash-verified

471 * @private
472 */
473 schedule_() {
474 if (this.scheduledImmediateInvocation_) {
475 return;
476 }
477 const nextTask = this.nextTask_();
478 if (!nextTask) {
479 return;
480 }
481 if (nextTask.immediateTriggerCondition_()) {
482 this.scheduledImmediateInvocation_ = true;
483 this.executeAsap_(/* idleDeadline */ null);
484 return;
485 }
486 // If requestIdleCallback exists, schedule a task with it, but
487 // do not wait longer than two seconds.
488 if (nextTask.useRequestIdleCallback_() && this.win_.requestIdleCallback) {
489 onIdle(
490 this.win_,
491 // Wait until we have a budget of at least 15ms.
492 // 15ms is a magic number. Budgets are higher when the user
493 // is completely idle (around 40), but that occurs too
494 // rarely to be usable. 15ms budgets can happen during scrolling
495 // but only if the device is doing super, super well, and no
496 // real processing is done between frames.
497 15 /* minimumTimeRemaining */,
498 2000 /* timeout */,
499 this.boundExecute_
500 );
501 return;
502 }
503 this.requestMacroTask_();
504 }
505
506 /**
507 * Requests executing of a macro task. Yields to the event queue

Callers 4

constructorMethod · 0.95
enqueueTask_Method · 0.95
execute_Method · 0.95
test-resources.jsFile · 0.45

Calls 6

nextTask_Method · 0.95
executeAsap_Method · 0.95
requestMacroTask_Method · 0.95
onIdleFunction · 0.85

Tested by

no test coverage detected