scheduler
Advanced tools
Comparing version 0.0.0-experimental-1a7472624 to 0.0.0-experimental-1fafac002
@@ -17,3 +17,3 @@ /** @license React vundefined | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = true; | ||
var enableProfiling = false; | ||
@@ -103,3 +103,2 @@ function push(heap, node) { | ||
// TODO: Use symbols? | ||
var NoPriority = 0; | ||
var ImmediatePriority = 1; | ||
@@ -111,163 +110,5 @@ var UserBlockingPriority = 2; | ||
var runIdCounter = 0; | ||
var mainThreadIdCounter = 0; | ||
var profilingStateSize = 4; | ||
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer | ||
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer | ||
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 | ||
; | ||
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks | ||
var PRIORITY = 0; | ||
var CURRENT_TASK_ID = 1; | ||
var CURRENT_RUN_ID = 2; | ||
var QUEUE_SIZE = 3; | ||
{ | ||
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue | ||
// array might include canceled tasks. | ||
profilingState[QUEUE_SIZE] = 0; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
} // Bytes per element is 4 | ||
var INITIAL_EVENT_LOG_SIZE = 131072; | ||
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes | ||
var eventLogSize = 0; | ||
var eventLogBuffer = null; | ||
var eventLog = null; | ||
var eventLogIndex = 0; | ||
var TaskStartEvent = 1; | ||
var TaskCompleteEvent = 2; | ||
var TaskErrorEvent = 3; | ||
var TaskCancelEvent = 4; | ||
var TaskRunEvent = 5; | ||
var TaskYieldEvent = 6; | ||
var SchedulerSuspendEvent = 7; | ||
var SchedulerResumeEvent = 8; | ||
function logEvent(entries) { | ||
if (eventLog !== null) { | ||
var offset = eventLogIndex; | ||
eventLogIndex += entries.length; | ||
if (eventLogIndex + 1 > eventLogSize) { | ||
eventLogSize *= 2; | ||
if (eventLogSize > MAX_EVENT_LOG_SIZE) { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); | ||
stopLoggingProfilingEvents(); | ||
return; | ||
} | ||
var newEventLog = new Int32Array(eventLogSize * 4); | ||
newEventLog.set(eventLog); | ||
eventLogBuffer = newEventLog.buffer; | ||
eventLog = newEventLog; | ||
} | ||
eventLog.set(entries, offset); | ||
} | ||
} | ||
function startLoggingProfilingEvents() { | ||
eventLogSize = INITIAL_EVENT_LOG_SIZE; | ||
eventLogBuffer = new ArrayBuffer(eventLogSize * 4); | ||
eventLog = new Int32Array(eventLogBuffer); | ||
eventLogIndex = 0; | ||
} | ||
function stopLoggingProfilingEvents() { | ||
var buffer = eventLogBuffer; | ||
eventLogSize = 0; | ||
eventLogBuffer = null; | ||
eventLog = null; | ||
eventLogIndex = 0; | ||
return buffer; | ||
} | ||
function markTaskStart(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]++; | ||
if (eventLog !== null) { | ||
// performance.now returns a float, representing milliseconds. When the | ||
// event is logged, it's coerced to an int. Convert to microseconds to | ||
// maintain extra degrees of precision. | ||
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); | ||
} | ||
} | ||
} | ||
function markTaskCompleted(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCompleteEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskCanceled(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCancelEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskErrored(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskErrorEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskRun(task, ms) { | ||
{ | ||
runIdCounter++; | ||
profilingState[PRIORITY] = task.priorityLevel; | ||
profilingState[CURRENT_TASK_ID] = task.id; | ||
profilingState[CURRENT_RUN_ID] = runIdCounter; | ||
if (eventLog !== null) { | ||
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markTaskYield(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[CURRENT_RUN_ID] = 0; | ||
if (eventLog !== null) { | ||
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerSuspended(ms) { | ||
{ | ||
mainThreadIdCounter++; | ||
if (eventLog !== null) { | ||
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerUnsuspended(ms) { | ||
{ | ||
if (eventLog !== null) { | ||
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
/* eslint-disable no-var */ | ||
@@ -321,7 +162,2 @@ // Math.pow(2, 30) - 1 | ||
push(taskQueue, timer); | ||
{ | ||
markTaskStart(timer, currentTime); | ||
timer.isQueued = true; | ||
} | ||
} else { | ||
@@ -355,5 +191,2 @@ // Remaining timers are pending. | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
{ | ||
markSchedulerUnsuspended(initialTime); | ||
} // We'll need a host callback the next time work is scheduled. | ||
@@ -393,8 +226,2 @@ | ||
isPerformingWork = false; | ||
{ | ||
var _currentTime = getCurrentTime(); | ||
markSchedulerSuspended(_currentTime); | ||
} | ||
} | ||
@@ -420,3 +247,3 @@ } | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
markTaskRun(currentTask, currentTime); | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
@@ -427,8 +254,3 @@ currentTime = getCurrentTime(); | ||
currentTask.callback = continuationCallback; | ||
markTaskYield(currentTask, currentTime); | ||
} else { | ||
{ | ||
markTaskCompleted(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
@@ -578,6 +400,2 @@ if (currentTask === peek(taskQueue)) { | ||
{ | ||
newTask.isQueued = false; | ||
} | ||
if (startTime > currentTime) { | ||
@@ -603,7 +421,2 @@ // This is a delayed task. | ||
push(taskQueue, newTask); | ||
{ | ||
markTaskStart(newTask, currentTime); | ||
newTask.isQueued = true; | ||
} // Schedule a host callback, if needed. If we're already performing work, | ||
// wait until the next time we yield. | ||
@@ -637,9 +450,2 @@ | ||
function unstable_cancelCallback(task) { | ||
{ | ||
if (task.isQueued) { | ||
var currentTime = getCurrentTime(); | ||
markTaskCanceled(task, currentTime); | ||
task.isQueued = false; | ||
} | ||
} // Null out the callback to indicate the task has been canceled. (Can't | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
@@ -868,7 +674,3 @@ // array based heap, only the first one.) | ||
} | ||
var unstable_Profiling = { | ||
startLoggingProfilingEvents: startLoggingProfilingEvents, | ||
stopLoggingProfilingEvents: stopLoggingProfilingEvents, | ||
sharedProfilingBuffer: sharedProfilingBuffer | ||
} ; | ||
var unstable_Profiling = null; | ||
@@ -875,0 +677,0 @@ exports.reset = reset; |
@@ -17,3 +17,3 @@ /** @license React vundefined | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = true; | ||
var enableProfiling = false; | ||
@@ -103,3 +103,2 @@ function push(heap, node) { | ||
// TODO: Use symbols? | ||
var NoPriority = 0; | ||
var ImmediatePriority = 1; | ||
@@ -111,163 +110,5 @@ var UserBlockingPriority = 2; | ||
var runIdCounter = 0; | ||
var mainThreadIdCounter = 0; | ||
var profilingStateSize = 4; | ||
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer | ||
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer | ||
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 | ||
; | ||
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks | ||
var PRIORITY = 0; | ||
var CURRENT_TASK_ID = 1; | ||
var CURRENT_RUN_ID = 2; | ||
var QUEUE_SIZE = 3; | ||
{ | ||
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue | ||
// array might include canceled tasks. | ||
profilingState[QUEUE_SIZE] = 0; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
} // Bytes per element is 4 | ||
var INITIAL_EVENT_LOG_SIZE = 131072; | ||
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes | ||
var eventLogSize = 0; | ||
var eventLogBuffer = null; | ||
var eventLog = null; | ||
var eventLogIndex = 0; | ||
var TaskStartEvent = 1; | ||
var TaskCompleteEvent = 2; | ||
var TaskErrorEvent = 3; | ||
var TaskCancelEvent = 4; | ||
var TaskRunEvent = 5; | ||
var TaskYieldEvent = 6; | ||
var SchedulerSuspendEvent = 7; | ||
var SchedulerResumeEvent = 8; | ||
function logEvent(entries) { | ||
if (eventLog !== null) { | ||
var offset = eventLogIndex; | ||
eventLogIndex += entries.length; | ||
if (eventLogIndex + 1 > eventLogSize) { | ||
eventLogSize *= 2; | ||
if (eventLogSize > MAX_EVENT_LOG_SIZE) { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); | ||
stopLoggingProfilingEvents(); | ||
return; | ||
} | ||
var newEventLog = new Int32Array(eventLogSize * 4); | ||
newEventLog.set(eventLog); | ||
eventLogBuffer = newEventLog.buffer; | ||
eventLog = newEventLog; | ||
} | ||
eventLog.set(entries, offset); | ||
} | ||
} | ||
function startLoggingProfilingEvents() { | ||
eventLogSize = INITIAL_EVENT_LOG_SIZE; | ||
eventLogBuffer = new ArrayBuffer(eventLogSize * 4); | ||
eventLog = new Int32Array(eventLogBuffer); | ||
eventLogIndex = 0; | ||
} | ||
function stopLoggingProfilingEvents() { | ||
var buffer = eventLogBuffer; | ||
eventLogSize = 0; | ||
eventLogBuffer = null; | ||
eventLog = null; | ||
eventLogIndex = 0; | ||
return buffer; | ||
} | ||
function markTaskStart(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]++; | ||
if (eventLog !== null) { | ||
// performance.now returns a float, representing milliseconds. When the | ||
// event is logged, it's coerced to an int. Convert to microseconds to | ||
// maintain extra degrees of precision. | ||
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); | ||
} | ||
} | ||
} | ||
function markTaskCompleted(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCompleteEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskCanceled(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCancelEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskErrored(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskErrorEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskRun(task, ms) { | ||
{ | ||
runIdCounter++; | ||
profilingState[PRIORITY] = task.priorityLevel; | ||
profilingState[CURRENT_TASK_ID] = task.id; | ||
profilingState[CURRENT_RUN_ID] = runIdCounter; | ||
if (eventLog !== null) { | ||
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markTaskYield(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[CURRENT_RUN_ID] = 0; | ||
if (eventLog !== null) { | ||
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerSuspended(ms) { | ||
{ | ||
mainThreadIdCounter++; | ||
if (eventLog !== null) { | ||
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerUnsuspended(ms) { | ||
{ | ||
if (eventLog !== null) { | ||
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
/* eslint-disable no-var */ | ||
@@ -328,7 +169,2 @@ // Math.pow(2, 30) - 1 | ||
push(taskQueue, timer); | ||
{ | ||
markTaskStart(timer, currentTime); | ||
timer.isQueued = true; | ||
} | ||
} else { | ||
@@ -362,5 +198,2 @@ // Remaining timers are pending. | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
{ | ||
markSchedulerUnsuspended(initialTime); | ||
} // We'll need a host callback the next time work is scheduled. | ||
@@ -400,8 +233,2 @@ | ||
isPerformingWork = false; | ||
{ | ||
var _currentTime = exports.unstable_now(); | ||
markSchedulerSuspended(_currentTime); | ||
} | ||
} | ||
@@ -427,3 +254,3 @@ } | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
markTaskRun(currentTask, currentTime); | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
@@ -434,8 +261,3 @@ currentTime = exports.unstable_now(); | ||
currentTask.callback = continuationCallback; | ||
markTaskYield(currentTask, currentTime); | ||
} else { | ||
{ | ||
markTaskCompleted(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
@@ -585,6 +407,2 @@ if (currentTask === peek(taskQueue)) { | ||
{ | ||
newTask.isQueued = false; | ||
} | ||
if (startTime > currentTime) { | ||
@@ -610,7 +428,2 @@ // This is a delayed task. | ||
push(taskQueue, newTask); | ||
{ | ||
markTaskStart(newTask, currentTime); | ||
newTask.isQueued = true; | ||
} // Schedule a host callback, if needed. If we're already performing work, | ||
// wait until the next time we yield. | ||
@@ -644,9 +457,2 @@ | ||
function unstable_cancelCallback(task) { | ||
{ | ||
if (task.isQueued) { | ||
var currentTime = exports.unstable_now(); | ||
markTaskCanceled(task, currentTime); | ||
task.isQueued = false; | ||
} | ||
} // Null out the callback to indicate the task has been canceled. (Can't | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
@@ -709,7 +515,3 @@ // array based heap, only the first one.) | ||
function requestPaint() {} | ||
var unstable_Profiling = { | ||
startLoggingProfilingEvents: startLoggingProfilingEvents, | ||
stopLoggingProfilingEvents: stopLoggingProfilingEvents, | ||
sharedProfilingBuffer: sharedProfilingBuffer | ||
} ; | ||
var unstable_Profiling = null; | ||
@@ -716,0 +518,0 @@ exports.unstable_IdlePriority = IdlePriority; |
@@ -17,3 +17,3 @@ /** @license React vundefined | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = true; | ||
var enableProfiling = false; | ||
@@ -103,3 +103,2 @@ function push(heap, node) { | ||
// TODO: Use symbols? | ||
var NoPriority = 0; | ||
var ImmediatePriority = 1; | ||
@@ -111,163 +110,5 @@ var UserBlockingPriority = 2; | ||
var runIdCounter = 0; | ||
var mainThreadIdCounter = 0; | ||
var profilingStateSize = 4; | ||
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer | ||
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer | ||
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 | ||
; | ||
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks | ||
var PRIORITY = 0; | ||
var CURRENT_TASK_ID = 1; | ||
var CURRENT_RUN_ID = 2; | ||
var QUEUE_SIZE = 3; | ||
{ | ||
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue | ||
// array might include canceled tasks. | ||
profilingState[QUEUE_SIZE] = 0; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
} // Bytes per element is 4 | ||
var INITIAL_EVENT_LOG_SIZE = 131072; | ||
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes | ||
var eventLogSize = 0; | ||
var eventLogBuffer = null; | ||
var eventLog = null; | ||
var eventLogIndex = 0; | ||
var TaskStartEvent = 1; | ||
var TaskCompleteEvent = 2; | ||
var TaskErrorEvent = 3; | ||
var TaskCancelEvent = 4; | ||
var TaskRunEvent = 5; | ||
var TaskYieldEvent = 6; | ||
var SchedulerSuspendEvent = 7; | ||
var SchedulerResumeEvent = 8; | ||
function logEvent(entries) { | ||
if (eventLog !== null) { | ||
var offset = eventLogIndex; | ||
eventLogIndex += entries.length; | ||
if (eventLogIndex + 1 > eventLogSize) { | ||
eventLogSize *= 2; | ||
if (eventLogSize > MAX_EVENT_LOG_SIZE) { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); | ||
stopLoggingProfilingEvents(); | ||
return; | ||
} | ||
var newEventLog = new Int32Array(eventLogSize * 4); | ||
newEventLog.set(eventLog); | ||
eventLogBuffer = newEventLog.buffer; | ||
eventLog = newEventLog; | ||
} | ||
eventLog.set(entries, offset); | ||
} | ||
} | ||
function startLoggingProfilingEvents() { | ||
eventLogSize = INITIAL_EVENT_LOG_SIZE; | ||
eventLogBuffer = new ArrayBuffer(eventLogSize * 4); | ||
eventLog = new Int32Array(eventLogBuffer); | ||
eventLogIndex = 0; | ||
} | ||
function stopLoggingProfilingEvents() { | ||
var buffer = eventLogBuffer; | ||
eventLogSize = 0; | ||
eventLogBuffer = null; | ||
eventLog = null; | ||
eventLogIndex = 0; | ||
return buffer; | ||
} | ||
function markTaskStart(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]++; | ||
if (eventLog !== null) { | ||
// performance.now returns a float, representing milliseconds. When the | ||
// event is logged, it's coerced to an int. Convert to microseconds to | ||
// maintain extra degrees of precision. | ||
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); | ||
} | ||
} | ||
} | ||
function markTaskCompleted(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCompleteEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskCanceled(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCancelEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskErrored(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskErrorEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskRun(task, ms) { | ||
{ | ||
runIdCounter++; | ||
profilingState[PRIORITY] = task.priorityLevel; | ||
profilingState[CURRENT_TASK_ID] = task.id; | ||
profilingState[CURRENT_RUN_ID] = runIdCounter; | ||
if (eventLog !== null) { | ||
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markTaskYield(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[CURRENT_RUN_ID] = 0; | ||
if (eventLog !== null) { | ||
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerSuspended(ms) { | ||
{ | ||
mainThreadIdCounter++; | ||
if (eventLog !== null) { | ||
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerUnsuspended(ms) { | ||
{ | ||
if (eventLog !== null) { | ||
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
/* eslint-disable no-var */ | ||
@@ -338,7 +179,2 @@ var perf = window.performance; | ||
push(taskQueue, timer); | ||
{ | ||
markTaskStart(timer, currentTime); | ||
timer.isQueued = true; | ||
} | ||
} else { | ||
@@ -372,5 +208,2 @@ // Remaining timers are pending. | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
{ | ||
markSchedulerUnsuspended(initialTime); | ||
} // We'll need a host callback the next time work is scheduled. | ||
@@ -410,8 +243,2 @@ | ||
isPerformingWork = false; | ||
{ | ||
var _currentTime = getCurrentTime(); | ||
markSchedulerSuspended(_currentTime); | ||
} | ||
} | ||
@@ -437,3 +264,3 @@ } | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
markTaskRun(currentTask, currentTime); | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
@@ -444,8 +271,3 @@ currentTime = getCurrentTime(); | ||
currentTask.callback = continuationCallback; | ||
markTaskYield(currentTask, currentTime); | ||
} else { | ||
{ | ||
markTaskCompleted(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
@@ -595,6 +417,2 @@ if (currentTask === peek(taskQueue)) { | ||
{ | ||
newTask.isQueued = false; | ||
} | ||
if (startTime > currentTime) { | ||
@@ -620,7 +438,2 @@ // This is a delayed task. | ||
push(taskQueue, newTask); | ||
{ | ||
markTaskStart(newTask, currentTime); | ||
newTask.isQueued = true; | ||
} // Schedule a host callback, if needed. If we're already performing work, | ||
// wait until the next time we yield. | ||
@@ -654,9 +467,2 @@ | ||
function unstable_cancelCallback(task) { | ||
{ | ||
if (task.isQueued) { | ||
var currentTime = getCurrentTime(); | ||
markTaskCanceled(task, currentTime); | ||
task.isQueued = false; | ||
} | ||
} // Null out the callback to indicate the task has been canceled. (Can't | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
@@ -769,7 +575,3 @@ // array based heap, only the first one.) | ||
var unstable_requestPaint = requestPaint; | ||
var unstable_Profiling = { | ||
startLoggingProfilingEvents: startLoggingProfilingEvents, | ||
stopLoggingProfilingEvents: stopLoggingProfilingEvents, | ||
sharedProfilingBuffer: sharedProfilingBuffer | ||
} ; | ||
var unstable_Profiling = null; | ||
@@ -776,0 +578,0 @@ exports.unstable_IdlePriority = IdlePriority; |
@@ -17,3 +17,3 @@ /** @license React vundefined | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = true; | ||
var enableProfiling = false; | ||
@@ -103,3 +103,2 @@ function push(heap, node) { | ||
// TODO: Use symbols? | ||
var NoPriority = 0; | ||
var ImmediatePriority = 1; | ||
@@ -111,163 +110,5 @@ var UserBlockingPriority = 2; | ||
var runIdCounter = 0; | ||
var mainThreadIdCounter = 0; | ||
var profilingStateSize = 4; | ||
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer | ||
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer | ||
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 | ||
; | ||
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks | ||
var PRIORITY = 0; | ||
var CURRENT_TASK_ID = 1; | ||
var CURRENT_RUN_ID = 2; | ||
var QUEUE_SIZE = 3; | ||
{ | ||
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue | ||
// array might include canceled tasks. | ||
profilingState[QUEUE_SIZE] = 0; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
} // Bytes per element is 4 | ||
var INITIAL_EVENT_LOG_SIZE = 131072; | ||
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes | ||
var eventLogSize = 0; | ||
var eventLogBuffer = null; | ||
var eventLog = null; | ||
var eventLogIndex = 0; | ||
var TaskStartEvent = 1; | ||
var TaskCompleteEvent = 2; | ||
var TaskErrorEvent = 3; | ||
var TaskCancelEvent = 4; | ||
var TaskRunEvent = 5; | ||
var TaskYieldEvent = 6; | ||
var SchedulerSuspendEvent = 7; | ||
var SchedulerResumeEvent = 8; | ||
function logEvent(entries) { | ||
if (eventLog !== null) { | ||
var offset = eventLogIndex; | ||
eventLogIndex += entries.length; | ||
if (eventLogIndex + 1 > eventLogSize) { | ||
eventLogSize *= 2; | ||
if (eventLogSize > MAX_EVENT_LOG_SIZE) { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); | ||
stopLoggingProfilingEvents(); | ||
return; | ||
} | ||
var newEventLog = new Int32Array(eventLogSize * 4); | ||
newEventLog.set(eventLog); | ||
eventLogBuffer = newEventLog.buffer; | ||
eventLog = newEventLog; | ||
} | ||
eventLog.set(entries, offset); | ||
} | ||
} | ||
function startLoggingProfilingEvents() { | ||
eventLogSize = INITIAL_EVENT_LOG_SIZE; | ||
eventLogBuffer = new ArrayBuffer(eventLogSize * 4); | ||
eventLog = new Int32Array(eventLogBuffer); | ||
eventLogIndex = 0; | ||
} | ||
function stopLoggingProfilingEvents() { | ||
var buffer = eventLogBuffer; | ||
eventLogSize = 0; | ||
eventLogBuffer = null; | ||
eventLog = null; | ||
eventLogIndex = 0; | ||
return buffer; | ||
} | ||
function markTaskStart(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]++; | ||
if (eventLog !== null) { | ||
// performance.now returns a float, representing milliseconds. When the | ||
// event is logged, it's coerced to an int. Convert to microseconds to | ||
// maintain extra degrees of precision. | ||
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); | ||
} | ||
} | ||
} | ||
function markTaskCompleted(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCompleteEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskCanceled(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCancelEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskErrored(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskErrorEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskRun(task, ms) { | ||
{ | ||
runIdCounter++; | ||
profilingState[PRIORITY] = task.priorityLevel; | ||
profilingState[CURRENT_TASK_ID] = task.id; | ||
profilingState[CURRENT_RUN_ID] = runIdCounter; | ||
if (eventLog !== null) { | ||
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markTaskYield(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[CURRENT_RUN_ID] = 0; | ||
if (eventLog !== null) { | ||
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerSuspended(ms) { | ||
{ | ||
mainThreadIdCounter++; | ||
if (eventLog !== null) { | ||
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerUnsuspended(ms) { | ||
{ | ||
if (eventLog !== null) { | ||
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
/* eslint-disable no-var */ | ||
@@ -318,2 +159,3 @@ | ||
var clearTimeout = window.clearTimeout; | ||
var setImmediate = window.setImmediate; // IE and Node.js + jsdom | ||
@@ -351,7 +193,2 @@ if (typeof console !== 'undefined') { | ||
push(taskQueue, timer); | ||
{ | ||
markTaskStart(timer, currentTime); | ||
timer.isQueued = true; | ||
} | ||
} else { | ||
@@ -385,5 +222,2 @@ // Remaining timers are pending. | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
{ | ||
markSchedulerUnsuspended(initialTime); | ||
} // We'll need a host callback the next time work is scheduled. | ||
@@ -423,8 +257,2 @@ | ||
isPerformingWork = false; | ||
{ | ||
var _currentTime = exports.unstable_now(); | ||
markSchedulerSuspended(_currentTime); | ||
} | ||
} | ||
@@ -450,3 +278,3 @@ } | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
markTaskRun(currentTask, currentTime); | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
@@ -457,8 +285,3 @@ currentTime = exports.unstable_now(); | ||
currentTask.callback = continuationCallback; | ||
markTaskYield(currentTask, currentTime); | ||
} else { | ||
{ | ||
markTaskCompleted(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
@@ -608,6 +431,2 @@ if (currentTask === peek(taskQueue)) { | ||
{ | ||
newTask.isQueued = false; | ||
} | ||
if (startTime > currentTime) { | ||
@@ -633,7 +452,2 @@ // This is a delayed task. | ||
push(taskQueue, newTask); | ||
{ | ||
markTaskStart(newTask, currentTime); | ||
newTask.isQueued = true; | ||
} // Schedule a host callback, if needed. If we're already performing work, | ||
// wait until the next time we yield. | ||
@@ -667,9 +481,2 @@ | ||
function unstable_cancelCallback(task) { | ||
{ | ||
if (task.isQueued) { | ||
var currentTime = exports.unstable_now(); | ||
markTaskCanceled(task, currentTime); | ||
task.isQueued = false; | ||
} | ||
} // Null out the callback to indicate the task has been canceled. (Can't | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
@@ -745,3 +552,3 @@ // array based heap, only the first one.) | ||
// of the preceding one. | ||
port.postMessage(null); | ||
schedulePerformWorkUntilDeadline(); | ||
} else { | ||
@@ -757,6 +564,29 @@ isMessageLoopRunning = false; | ||
var channel = new MessageChannel(); | ||
var port = channel.port2; | ||
channel.port1.onmessage = performWorkUntilDeadline; | ||
var schedulePerformWorkUntilDeadline; | ||
if (typeof setImmediate === 'function') { | ||
// Node.js and old IE. | ||
// There's a few reasons for why we prefer setImmediate. | ||
// | ||
// Unlike MessageChannel, it doesn't prevent a Node.js process from exiting. | ||
// (Even though this is a DOM fork of the Scheduler, you could get here | ||
// with a mix of Node.js 15+, which has a MessageChannel, and jsdom.) | ||
// https://github.com/facebook/react/issues/20756 | ||
// | ||
// But also, it runs earlier which is the semantic we want. | ||
// If other browsers ever implement it, it's better to use it. | ||
// Although both of these would be inferior to native scheduling. | ||
schedulePerformWorkUntilDeadline = function () { | ||
setImmediate(performWorkUntilDeadline); | ||
}; | ||
} else { | ||
var channel = new MessageChannel(); | ||
var port = channel.port2; | ||
channel.port1.onmessage = performWorkUntilDeadline; | ||
schedulePerformWorkUntilDeadline = function () { | ||
port.postMessage(null); | ||
}; | ||
} | ||
function requestHostCallback(callback) { | ||
@@ -767,3 +597,3 @@ scheduledHostCallback = callback; | ||
isMessageLoopRunning = true; | ||
port.postMessage(null); | ||
schedulePerformWorkUntilDeadline(); | ||
} | ||
@@ -784,7 +614,3 @@ } | ||
var unstable_requestPaint = requestPaint; | ||
var unstable_Profiling = { | ||
startLoggingProfilingEvents: startLoggingProfilingEvents, | ||
stopLoggingProfilingEvents: stopLoggingProfilingEvents, | ||
sharedProfilingBuffer: sharedProfilingBuffer | ||
} ; | ||
var unstable_Profiling = null; | ||
@@ -791,0 +617,0 @@ exports.unstable_IdlePriority = IdlePriority; |
@@ -10,10 +10,10 @@ /** @license React vundefined | ||
'use strict';function f(a,b){var c=a.length;a.push(b);a:for(;;){var d=c-1>>>1,e=a[d];if(void 0!==e&&0<g(e,b))a[d]=b,a[c]=e,c=d;else break a}}function h(a){a=a[0];return void 0===a?null:a}function k(a){var b=a[0];if(void 0!==b){var c=a.pop();if(c!==b){a[0]=c;a:for(var d=0,e=a.length;d<e;){var m=2*(d+1)-1,n=a[m],r=m+1,q=a[r];if(void 0!==n&&0>g(n,c))void 0!==q&&0>g(q,n)?(a[d]=q,a[r]=c,d=r):(a[d]=n,a[m]=c,d=m);else if(void 0!==q&&0>g(q,c))a[d]=q,a[r]=c,d=r;else break a}}return b}return null} | ||
function g(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}if("object"===typeof performance&&"function"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()}}else{var p=Date,t=p.now();exports.unstable_now=function(){return p.now()-t}}var u=[],v=[],w=1,x=null,y=3,z=!1,A=!1,B=!1,C=window.setTimeout,D=window.clearTimeout; | ||
if("undefined"!==typeof console){var E=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");"function"!==typeof E&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")} | ||
function F(a){for(var b=h(v);null!==b;){if(null===b.callback)k(v);else if(b.startTime<=a)k(v),b.sortIndex=b.expirationTime,f(u,b);else break;b=h(v)}}function G(a){B=!1;F(a);if(!A)if(null!==h(u))A=!0,H(I);else{var b=h(v);null!==b&&J(G,b.startTime-a)}} | ||
function I(a,b){A=!1;B&&(B=!1,D(K),K=-1);z=!0;var c=y;try{F(b);for(x=h(u);null!==x&&(!(x.expirationTime>b)||a&&!L());){var d=x.callback;if("function"===typeof d){x.callback=null;y=x.priorityLevel;var e=d(x.expirationTime<=b);b=exports.unstable_now();"function"===typeof e?x.callback=e:x===h(u)&&k(u);F(b)}else k(u);x=h(u)}if(null!==x)var m=!0;else{var n=h(v);null!==n&&J(G,n.startTime-b);m=!1}return m}finally{x=null,y=c,z=!1}}var M=!1,N=null,K=-1,O=5,P=0; | ||
function L(){return exports.unstable_now()>=P}var Q=new MessageChannel,R=Q.port2;Q.port1.onmessage=function(){if(null!==N){var a=exports.unstable_now();P=a+O;var b=!0;try{b=N(!0,a)}finally{b?R.postMessage(null):(M=!1,N=null)}}else M=!1};function H(a){N=a;M||(M=!0,R.postMessage(null))}function J(a,b){K=C(function(){a(exports.unstable_now())},b)}exports.unstable_IdlePriority=5;exports.unstable_ImmediatePriority=1;exports.unstable_LowPriority=4;exports.unstable_NormalPriority=3; | ||
exports.unstable_Profiling=null;exports.unstable_UserBlockingPriority=2;exports.unstable_cancelCallback=function(a){a.callback=null};exports.unstable_continueExecution=function(){A||z||(A=!0,H(I))};exports.unstable_forceFrameRate=function(a){0>a||125<a?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<a?Math.floor(1E3/a):5};exports.unstable_getCurrentPriorityLevel=function(){return y}; | ||
exports.unstable_getFirstCallbackNode=function(){return h(u)};exports.unstable_next=function(a){switch(y){case 1:case 2:case 3:var b=3;break;default:b=y}var c=y;y=b;try{return a()}finally{y=c}};exports.unstable_pauseExecution=function(){};exports.unstable_requestPaint=function(){};exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=y;y=a;try{return b()}finally{y=c}}; | ||
exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();"object"===typeof c&&null!==c?(c=c.delay,c="number"===typeof c&&0<c?d+c:d):c=d;switch(a){case 1:var e=-1;break;case 2:e=250;break;case 5:e=1073741823;break;case 4:e=1E4;break;default:e=5E3}e=c+e;a={id:w++,callback:b,priorityLevel:a,startTime:c,expirationTime:e,sortIndex:-1};c>d?(a.sortIndex=c,f(v,a),null===h(u)&&a===h(v)&&(B?(D(K),K=-1):B=!0,J(G,c-d))):(a.sortIndex=e,f(u,a),A||z||(A=!0,H(I)));return a}; | ||
exports.unstable_shouldYield=L;exports.unstable_wrapCallback=function(a){var b=y;return function(){var c=y;y=b;try{return a.apply(this,arguments)}finally{y=c}}}; | ||
function g(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}if("object"===typeof performance&&"function"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()}}else{var p=Date,t=p.now();exports.unstable_now=function(){return p.now()-t}}var u=[],v=[],w=1,x=null,y=3,z=!1,A=!1,B=!1,C=window.setTimeout,D=window.clearTimeout,E=window.setImmediate; | ||
if("undefined"!==typeof console){var F=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");"function"!==typeof F&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")} | ||
function G(a){for(var b=h(v);null!==b;){if(null===b.callback)k(v);else if(b.startTime<=a)k(v),b.sortIndex=b.expirationTime,f(u,b);else break;b=h(v)}}function H(a){B=!1;G(a);if(!A)if(null!==h(u))A=!0,I(J);else{var b=h(v);null!==b&&K(H,b.startTime-a)}} | ||
function J(a,b){A=!1;B&&(B=!1,D(L),L=-1);z=!0;var c=y;try{G(b);for(x=h(u);null!==x&&(!(x.expirationTime>b)||a&&!M());){var d=x.callback;if("function"===typeof d){x.callback=null;y=x.priorityLevel;var e=d(x.expirationTime<=b);b=exports.unstable_now();"function"===typeof e?x.callback=e:x===h(u)&&k(u);G(b)}else k(u);x=h(u)}if(null!==x)var m=!0;else{var n=h(v);null!==n&&K(H,n.startTime-b);m=!1}return m}finally{x=null,y=c,z=!1}}var N=!1,O=null,L=-1,P=5,Q=0; | ||
function M(){return exports.unstable_now()>=Q}function R(){if(null!==O){var a=exports.unstable_now();Q=a+P;var b=!0;try{b=O(!0,a)}finally{b?S():(N=!1,O=null)}}else N=!1}var S;if("function"===typeof E)S=function(){E(R)};else{var T=new MessageChannel,U=T.port2;T.port1.onmessage=R;S=function(){U.postMessage(null)}}function I(a){O=a;N||(N=!0,S())}function K(a,b){L=C(function(){a(exports.unstable_now())},b)}exports.unstable_IdlePriority=5;exports.unstable_ImmediatePriority=1; | ||
exports.unstable_LowPriority=4;exports.unstable_NormalPriority=3;exports.unstable_Profiling=null;exports.unstable_UserBlockingPriority=2;exports.unstable_cancelCallback=function(a){a.callback=null};exports.unstable_continueExecution=function(){A||z||(A=!0,I(J))};exports.unstable_forceFrameRate=function(a){0>a||125<a?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<a?Math.floor(1E3/a):5}; | ||
exports.unstable_getCurrentPriorityLevel=function(){return y};exports.unstable_getFirstCallbackNode=function(){return h(u)};exports.unstable_next=function(a){switch(y){case 1:case 2:case 3:var b=3;break;default:b=y}var c=y;y=b;try{return a()}finally{y=c}};exports.unstable_pauseExecution=function(){};exports.unstable_requestPaint=function(){};exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=y;y=a;try{return b()}finally{y=c}}; | ||
exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();"object"===typeof c&&null!==c?(c=c.delay,c="number"===typeof c&&0<c?d+c:d):c=d;switch(a){case 1:var e=-1;break;case 2:e=250;break;case 5:e=1073741823;break;case 4:e=1E4;break;default:e=5E3}e=c+e;a={id:w++,callback:b,priorityLevel:a,startTime:c,expirationTime:e,sortIndex:-1};c>d?(a.sortIndex=c,f(v,a),null===h(u)&&a===h(v)&&(B?(D(L),L=-1):B=!0,K(H,c-d))):(a.sortIndex=e,f(u,a),A||z||(A=!0,I(J)));return a}; | ||
exports.unstable_shouldYield=M;exports.unstable_wrapCallback=function(a){var b=y;return function(){var c=y;y=b;try{return a.apply(this,arguments)}finally{y=c}}}; |
{ | ||
"name": "scheduler", | ||
"version": "0.0.0-experimental-1a7472624", | ||
"version": "0.0.0-experimental-1fafac002", | ||
"description": "Cooperative scheduler for the browser environment.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,3 @@ /** @license React vundefined | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = true; | ||
var enableProfiling = false; | ||
@@ -102,3 +102,2 @@ function push(heap, node) { | ||
// TODO: Use symbols? | ||
var NoPriority = 0; | ||
var ImmediatePriority = 1; | ||
@@ -110,163 +109,5 @@ var UserBlockingPriority = 2; | ||
var runIdCounter = 0; | ||
var mainThreadIdCounter = 0; | ||
var profilingStateSize = 4; | ||
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer | ||
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer | ||
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 | ||
; | ||
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks | ||
var PRIORITY = 0; | ||
var CURRENT_TASK_ID = 1; | ||
var CURRENT_RUN_ID = 2; | ||
var QUEUE_SIZE = 3; | ||
{ | ||
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue | ||
// array might include canceled tasks. | ||
profilingState[QUEUE_SIZE] = 0; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
} // Bytes per element is 4 | ||
var INITIAL_EVENT_LOG_SIZE = 131072; | ||
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes | ||
var eventLogSize = 0; | ||
var eventLogBuffer = null; | ||
var eventLog = null; | ||
var eventLogIndex = 0; | ||
var TaskStartEvent = 1; | ||
var TaskCompleteEvent = 2; | ||
var TaskErrorEvent = 3; | ||
var TaskCancelEvent = 4; | ||
var TaskRunEvent = 5; | ||
var TaskYieldEvent = 6; | ||
var SchedulerSuspendEvent = 7; | ||
var SchedulerResumeEvent = 8; | ||
function logEvent(entries) { | ||
if (eventLog !== null) { | ||
var offset = eventLogIndex; | ||
eventLogIndex += entries.length; | ||
if (eventLogIndex + 1 > eventLogSize) { | ||
eventLogSize *= 2; | ||
if (eventLogSize > MAX_EVENT_LOG_SIZE) { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); | ||
stopLoggingProfilingEvents(); | ||
return; | ||
} | ||
var newEventLog = new Int32Array(eventLogSize * 4); | ||
newEventLog.set(eventLog); | ||
eventLogBuffer = newEventLog.buffer; | ||
eventLog = newEventLog; | ||
} | ||
eventLog.set(entries, offset); | ||
} | ||
} | ||
function startLoggingProfilingEvents() { | ||
eventLogSize = INITIAL_EVENT_LOG_SIZE; | ||
eventLogBuffer = new ArrayBuffer(eventLogSize * 4); | ||
eventLog = new Int32Array(eventLogBuffer); | ||
eventLogIndex = 0; | ||
} | ||
function stopLoggingProfilingEvents() { | ||
var buffer = eventLogBuffer; | ||
eventLogSize = 0; | ||
eventLogBuffer = null; | ||
eventLog = null; | ||
eventLogIndex = 0; | ||
return buffer; | ||
} | ||
function markTaskStart(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]++; | ||
if (eventLog !== null) { | ||
// performance.now returns a float, representing milliseconds. When the | ||
// event is logged, it's coerced to an int. Convert to microseconds to | ||
// maintain extra degrees of precision. | ||
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); | ||
} | ||
} | ||
} | ||
function markTaskCompleted(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCompleteEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskCanceled(task, ms) { | ||
{ | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskCancelEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskErrored(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[QUEUE_SIZE]--; | ||
if (eventLog !== null) { | ||
logEvent([TaskErrorEvent, ms * 1000, task.id]); | ||
} | ||
} | ||
} | ||
function markTaskRun(task, ms) { | ||
{ | ||
runIdCounter++; | ||
profilingState[PRIORITY] = task.priorityLevel; | ||
profilingState[CURRENT_TASK_ID] = task.id; | ||
profilingState[CURRENT_RUN_ID] = runIdCounter; | ||
if (eventLog !== null) { | ||
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markTaskYield(task, ms) { | ||
{ | ||
profilingState[PRIORITY] = NoPriority; | ||
profilingState[CURRENT_TASK_ID] = 0; | ||
profilingState[CURRENT_RUN_ID] = 0; | ||
if (eventLog !== null) { | ||
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerSuspended(ms) { | ||
{ | ||
mainThreadIdCounter++; | ||
if (eventLog !== null) { | ||
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
function markSchedulerUnsuspended(ms) { | ||
{ | ||
if (eventLog !== null) { | ||
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); | ||
} | ||
} | ||
} | ||
/* eslint-disable no-var */ | ||
@@ -320,7 +161,2 @@ // Math.pow(2, 30) - 1 | ||
push(taskQueue, timer); | ||
{ | ||
markTaskStart(timer, currentTime); | ||
timer.isQueued = true; | ||
} | ||
} else { | ||
@@ -354,5 +190,2 @@ // Remaining timers are pending. | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
{ | ||
markSchedulerUnsuspended(initialTime); | ||
} // We'll need a host callback the next time work is scheduled. | ||
@@ -392,8 +225,2 @@ | ||
isPerformingWork = false; | ||
{ | ||
var _currentTime = getCurrentTime(); | ||
markSchedulerSuspended(_currentTime); | ||
} | ||
} | ||
@@ -419,3 +246,3 @@ } | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
markTaskRun(currentTask, currentTime); | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
@@ -426,8 +253,3 @@ currentTime = getCurrentTime(); | ||
currentTask.callback = continuationCallback; | ||
markTaskYield(currentTask, currentTime); | ||
} else { | ||
{ | ||
markTaskCompleted(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
@@ -577,6 +399,2 @@ if (currentTask === peek(taskQueue)) { | ||
{ | ||
newTask.isQueued = false; | ||
} | ||
if (startTime > currentTime) { | ||
@@ -602,7 +420,2 @@ // This is a delayed task. | ||
push(taskQueue, newTask); | ||
{ | ||
markTaskStart(newTask, currentTime); | ||
newTask.isQueued = true; | ||
} // Schedule a host callback, if needed. If we're already performing work, | ||
// wait until the next time we yield. | ||
@@ -636,9 +449,2 @@ | ||
function unstable_cancelCallback(task) { | ||
{ | ||
if (task.isQueued) { | ||
var currentTime = getCurrentTime(); | ||
markTaskCanceled(task, currentTime); | ||
task.isQueued = false; | ||
} | ||
} // Null out the callback to indicate the task has been canceled. (Can't | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
@@ -867,7 +673,3 @@ // array based heap, only the first one.) | ||
} | ||
var unstable_Profiling = { | ||
startLoggingProfilingEvents: startLoggingProfilingEvents, | ||
stopLoggingProfilingEvents: stopLoggingProfilingEvents, | ||
sharedProfilingBuffer: sharedProfilingBuffer | ||
} ; | ||
var unstable_Profiling = null; | ||
@@ -874,0 +676,0 @@ exports.reset = reset; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150366
3844