(hasTimeRemaining, initialTime)
| 3407 | } |
| 3408 | |
| 3409 | function workLoop(hasTimeRemaining, initialTime) { |
| 3410 | var currentTime = initialTime; |
| 3411 | advanceTimers(currentTime); |
| 3412 | currentTask = peek(taskQueue); |
| 3413 | |
| 3414 | while (currentTask !== null && !(enableSchedulerDebugging )) { |
| 3415 | if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { |
| 3416 | // This currentTask hasn't expired, and we've reached the deadline. |
| 3417 | break; |
| 3418 | } |
| 3419 | |
| 3420 | var callback = currentTask.callback; |
| 3421 | |
| 3422 | if (callback !== null) { |
| 3423 | currentTask.callback = null; |
| 3424 | currentPriorityLevel = currentTask.priorityLevel; |
| 3425 | var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; |
| 3426 | markTaskRun(currentTask, currentTime); |
| 3427 | var continuationCallback = callback(didUserCallbackTimeout); |
| 3428 | currentTime = exports.unstable_now(); |
| 3429 | |
| 3430 | if (typeof continuationCallback === 'function') { |
| 3431 | currentTask.callback = continuationCallback; |
| 3432 | markTaskYield(currentTask, currentTime); |
| 3433 | } else { |
| 3434 | { |
| 3435 | markTaskCompleted(currentTask, currentTime); |
| 3436 | currentTask.isQueued = false; |
| 3437 | } |
| 3438 | |
| 3439 | if (currentTask === peek(taskQueue)) { |
| 3440 | pop(taskQueue); |
| 3441 | } |
| 3442 | } |
| 3443 | |
| 3444 | advanceTimers(currentTime); |
| 3445 | } else { |
| 3446 | pop(taskQueue); |
| 3447 | } |
| 3448 | |
| 3449 | currentTask = peek(taskQueue); |
| 3450 | } // Return whether there's additional work |
| 3451 | |
| 3452 | |
| 3453 | if (currentTask !== null) { |
| 3454 | return true; |
| 3455 | } else { |
| 3456 | var firstTimer = peek(timerQueue); |
| 3457 | |
| 3458 | if (firstTimer !== null) { |
| 3459 | requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); |
| 3460 | } |
| 3461 | |
| 3462 | return false; |
| 3463 | } |
| 3464 | } |
| 3465 | |
| 3466 | function unstable_runWithPriority(priorityLevel, eventHandler) { |
no test coverage detected