@@ -462,9 +462,6 @@ function unstable_getCurrentPriorityLevel(): PriorityLevel {
462
462
}
463
463
464
464
let isMessageLoopRunning = false ;
465
- let scheduledHostCallback :
466
- | null
467
- | ( ( initialTime : DOMHighResTimeStamp | number ) => boolean ) = null ;
468
465
let taskTimeoutID : TimeoutID = ( - 1 : any ) ;
469
466
470
467
// Scheduler periodically yields in case there is other work on the main
@@ -556,7 +553,7 @@ function forceFrameRate(fps: number) {
556
553
}
557
554
558
555
const performWorkUntilDeadline = ( ) => {
559
- if ( scheduledHostCallback !== null ) {
556
+ if ( isMessageLoopRunning ) {
560
557
const currentTime = getCurrentTime ( ) ;
561
558
// Keep track of the start time so we can measure how long the main thread
562
559
// has been blocked.
@@ -566,24 +563,20 @@ const performWorkUntilDeadline = () => {
566
563
// error can be observed.
567
564
//
568
565
// Intentionally not using a try-catch, since that makes some debugging
569
- // techniques harder. Instead, if `scheduledHostCallback ` errors, then
570
- // `hasMoreWork` will remain true, and we'll continue the work loop.
566
+ // techniques harder. Instead, if `flushWork ` errors, then `hasMoreWork` will
567
+ // remain true, and we'll continue the work loop.
571
568
let hasMoreWork = true ;
572
569
try {
573
- // $FlowFixMe[not-a-function] found when upgrading Flow
574
- hasMoreWork = scheduledHostCallback ( currentTime ) ;
570
+ hasMoreWork = flushWork ( currentTime ) ;
575
571
} finally {
576
572
if ( hasMoreWork ) {
577
573
// If there's more work, schedule the next message event at the end
578
574
// of the preceding one.
579
575
schedulePerformWorkUntilDeadline ( ) ;
580
576
} else {
581
577
isMessageLoopRunning = false ;
582
- scheduledHostCallback = null ;
583
578
}
584
579
}
585
- } else {
586
- isMessageLoopRunning = false ;
587
580
}
588
581
// Yielding to the browser will give it a chance to paint, so we can
589
582
// reset this.
@@ -624,7 +617,6 @@ if (typeof localSetImmediate === 'function') {
624
617
}
625
618
626
619
function requestHostCallback ( callback : ( initialTime : number ) = > boolean ) {
627
- scheduledHostCallback = callback ;
628
620
if ( ! isMessageLoopRunning ) {
629
621
isMessageLoopRunning = true ;
630
622
schedulePerformWorkUntilDeadline ( ) ;
0 commit comments