Closed thomas-void0 closed 2 years ago
主要是考虑到其中!(enableSchedulerDebugging && isSchedulerPaused)
是属于开启调试过程才会执行, 所以正常运行时他必然为true, 所以当初在分析源码时为了简洁没有加上.
真正对于暂停的判定应该是下面的if中(!hasTimeRemaining || shouldYieldToHost())
if (
currentTask.expirationTime > currentTime &&
(!hasTimeRemaining || shouldYieldToHost())
) {
// This currentTask hasn't expired, and we've reached the deadline.
break;
}
你看一下是不是这个原理
真正对于暂停的判定应该是下面的if中
(!hasTimeRemaining || shouldYieldToHost())
if ( currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost()) ) { // This currentTask hasn't expired, and we've reached the deadline. break; }
你看一下是不是这个原理
感谢你的回复,确实是这样。之前看的还是不够仔细。打扰了😄
我再workLoop源码讲解这里遇到了一些问题,我通过阅读示例的伪代码发现。如下所示: 红色部分的判断中缺少了对于暂停的判断,所以我对后面蓝色部分的代码产生了执行疑惑。通过对照源码我才发现while判读还有一部分条件。
所以我提出了一点小小的优化,在伪代码处将while循环的条件补齐。还有就是在此位置增加workLoop的源码链接。方便点击对照进行查看。