[Scheduler] Temporarily remove wrapper function (#16345)
This code is being compiled incorrectly by something in the Facebook build pipeline. I'm removing it temporarily to unblock the sync while we investigate.
Andrew Clark committed
Aug 9, 2019 at 18:08 UTC
e349da19b8423182c65dbf6ce38a9aeb61dbf529
2 files changed
+25
-75
packages/scheduler/src/Scheduler.js
+22
-74
@@ -60,71 +60,13 @@ var isPerformingWork = false;
60
var isHostCallbackScheduled = false;
61
var isHostTimeoutScheduled = false;
62
63
-function scheduler_flushTaskAtPriority_Immediate(callback, didTimeout) {
64
- return callback(didTimeout);
65
-}
66
-function scheduler_flushTaskAtPriority_UserBlocking(callback, didTimeout) {
67
- return callback(didTimeout);
68
-}
69
-function scheduler_flushTaskAtPriority_Normal(callback, didTimeout) {
70
- return callback(didTimeout);
71
-}
72
-function scheduler_flushTaskAtPriority_Low(callback, didTimeout) {
73
- return callback(didTimeout);
74
-}
75
-function scheduler_flushTaskAtPriority_Idle(callback, didTimeout) {
76
- return callback(didTimeout);
77
-}
78
-
63
function flushTask(task, callback, currentTime) {
80
- var previousPriorityLevel = currentPriorityLevel;
81
- var previousTask = currentTask;
64
currentPriorityLevel = task.priorityLevel;
83
- currentTask = task;
84
- try {
85
- var didUserCallbackTimeout = task.expirationTime <= currentTime;
86
- // Add an extra function to the callstack. Profiling tools can use this
87
- // to infer the priority of work that appears higher in the stack.
88
- var continuationCallback;
89
- switch (currentPriorityLevel) {
90
- case ImmediatePriority:
91
- continuationCallback = scheduler_flushTaskAtPriority_Immediate(
92
- callback,
93
- didUserCallbackTimeout,
94
- );
95
- break;
96
- case UserBlockingPriority:
97
- continuationCallback = scheduler_flushTaskAtPriority_UserBlocking(
98
- callback,
99
- didUserCallbackTimeout,
100
- );
101
- break;
102
- case NormalPriority:
103
- continuationCallback = scheduler_flushTaskAtPriority_Normal(
104
- callback,
105
- didUserCallbackTimeout,
106
- );
107
- break;
108
- case LowPriority:
109
- continuationCallback = scheduler_flushTaskAtPriority_Low(
110
- callback,
111
- didUserCallbackTimeout,
112
- );
113
- break;
114
- case IdlePriority:
115
- continuationCallback = scheduler_flushTaskAtPriority_Idle(
116
- callback,
117
- didUserCallbackTimeout,
118
- );
119
- break;
120
- }
121
- return typeof continuationCallback === 'function'
122
- ? continuationCallback
123
- : null;
124
- } finally {
125
- currentPriorityLevel = previousPriorityLevel;
126
- currentTask = previousTask;
127
- }
65
+ var didUserCallbackTimeout = task.expirationTime <= currentTime;
66
+ var continuationCallback = callback(didUserCallbackTimeout);
67
+ return typeof continuationCallback === 'function'
68
+ ? continuationCallback
69
+ : null;
70
}
71
72
function advanceTimers(currentTime) {
@@ -174,26 +116,30 @@ function flushWork(hasTimeRemaining, initialTime) {
116
}
117
118
isPerformingWork = true;
119
+ const previousPriorityLevel = currentPriorityLevel;
120
try {
121
let currentTime = initialTime;
122
advanceTimers(currentTime);
180
- let task = peek(taskQueue);
181
- while (task !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {
123
+ currentTask = peek(taskQueue);
124
+ while (
125
+ currentTask !== null &&
126
+ !(enableSchedulerDebugging && isSchedulerPaused)
127
+ ) {
128
if (
183
- task.expirationTime > currentTime &&
129
+ currentTask.expirationTime > currentTime &&
130
(!hasTimeRemaining || shouldYieldToHost())
131
) {
186
- // This task hasn't expired, and we've reached the deadline.
132
+ // This currentTask hasn't expired, and we've reached the deadline.
133
break;
134
}
189
- const callback = task.callback;
135
+ const callback = currentTask.callback;
136
if (callback !== null) {
191
- task.callback = null;
192
- const continuation = flushTask(task, callback, currentTime);
137
+ currentTask.callback = null;
138
+ const continuation = flushTask(currentTask, callback, currentTime);
139
if (continuation !== null) {
194
- task.callback = continuation;
140
+ currentTask.callback = continuation;
141
} else {
196
- if (task === peek(taskQueue)) {
142
+ if (currentTask === peek(taskQueue)) {
143
pop(taskQueue);
144
}
145
}
@@ -202,10 +148,10 @@ function flushWork(hasTimeRemaining, initialTime) {
148
} else {
149
pop(taskQueue);
150
}
205
- task = peek(taskQueue);
151
+ currentTask = peek(taskQueue);
152
}
153
// Return whether there's additional work
208
- if (task !== null) {
154
+ if (currentTask !== null) {
155
return true;
156
} else {
157
let firstTimer = peek(timerQueue);
@@ -215,6 +161,8 @@ function flushWork(hasTimeRemaining, initialTime) {
161
return false;
162
}
163
} finally {
164
+ currentTask = null;
165
+ currentPriorityLevel = previousPriorityLevel;
166
isPerformingWork = false;
167
}
168
}
packages/scheduler/src/__tests__/Scheduler-test.js
+3
-1
@@ -434,7 +434,9 @@ describe('Scheduler', () => {
434
if (__DEV__) {
435
// Function names are minified in prod, though you could still infer the
436
// priority if you have sourcemaps.
437
- it('adds extra function to the JS stack whose name includes the priority level', () => {
437
+ // TODO: Feature temporarily disabled while we investigate a bug in one of
438
+ // our minifiers.
439
+ it.skip('adds extra function to the JS stack whose name includes the priority level', () => {
440
function inferPriorityFromCallstack() {
441
try {
442
throw Error();