* Schedule running the next queued task. * @private
()
| 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 |
no test coverage detected