Skip to content

Commit 97401cb

Browse files
n1ru4lfacebook-github-bot
authored andcommittedNov 12, 2020
feat: mark _scheduleGC public by renaming it to scheduleGC. (#3167)
Summary: Some applications might need to schedule a garbage collection more often. Reference Issue: #3165 josephsavona Pull Request resolved: #3167 Reviewed By: josephsavona Differential Revision: D24910032 Pulled By: poteto fbshipit-source-id: 15e7b25e90d778e4852ebc90fca5920ea28f0d87
1 parent ceb19d6 commit 97401cb

4 files changed

+16
-9
lines changed
 

‎packages/relay-runtime/store/RelayModernStore.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class RelayModernStore implements Store {
233233

234234
if (rootEntryIsStale) {
235235
this._roots.delete(id);
236-
this._scheduleGC();
236+
this.scheduleGC();
237237
} else {
238238
this._releaseBuffer.push(id);
239239

@@ -243,7 +243,7 @@ class RelayModernStore implements Store {
243243
if (this._releaseBuffer.length > this._gcReleaseBufferSize) {
244244
const _id = this._releaseBuffer.shift();
245245
this._roots.delete(_id);
246-
this._scheduleGC();
246+
this.scheduleGC();
247247
}
248248
}
249249
}
@@ -413,7 +413,7 @@ class RelayModernStore implements Store {
413413
if (this._gcHoldCounter > 0) {
414414
this._gcHoldCounter--;
415415
if (this._gcHoldCounter === 0 && this._shouldScheduleGC) {
416-
this._scheduleGC();
416+
this.scheduleGC();
417417
this._shouldScheduleGC = false;
418418
}
419419
}
@@ -592,7 +592,7 @@ class RelayModernStore implements Store {
592592
}
593593
this._optimisticSource = null;
594594
if (this._shouldScheduleGC) {
595-
this._scheduleGC();
595+
this.scheduleGC();
596596
}
597597
this._subscriptions.forEach(subscription => {
598598
const backup = subscription.backup;
@@ -614,7 +614,7 @@ class RelayModernStore implements Store {
614614
});
615615
}
616616

617-
_scheduleGC() {
617+
scheduleGC() {
618618
if (this._gcHoldCounter > 0) {
619619
this._shouldScheduleGC = true;
620620
return;

‎packages/relay-runtime/store/__tests__/RelayModernEnvironment-ExecuteWithFlight-test.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ describe('execute() with Flight field', () => {
161161
expect(complete).toBeCalledTimes(0);
162162
expect(error).toBeCalledTimes(0);
163163
expect(reactFlightPayloadDeserializer).toBeCalledTimes(1);
164-
store.__gc();
164+
165+
store.scheduleGC();
166+
jest.runAllTimers();
167+
165168
expect(environment.lookup(innerOperation.fragment).data).toEqual({
166169
node: {
167170
name: 'Lauren',
@@ -259,7 +262,10 @@ describe('execute() with Flight field', () => {
259262
expect(complete).toBeCalledTimes(0);
260263
expect(error).toBeCalledTimes(0);
261264
expect(reactFlightPayloadDeserializer).toBeCalledTimes(1);
262-
store.__gc(); // Invoke gc to verify that data is retained
265+
266+
store.scheduleGC(); // Invoke gc to verify that data is retained
267+
jest.runAllTimers();
268+
263269
expect(environment.lookup(innerOperation.fragment).data).toEqual({
264270
node: {
265271
name: 'Lauren',

‎packages/relay-runtime/store/__tests__/RelayModernEnvironment-ExecuteWithStreamedConnection-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ describe('execute() fetches a @stream-ed @connection', () => {
13261326
callback.mockClear();
13271327

13281328
// Triggers a GC
1329-
store.__gc();
1329+
store.scheduleGC();
13301330
jest.runAllTimers();
13311331

13321332
// Second edge should be appended correctly

‎packages/relay-runtime/store/__tests__/RelayModernEnvironment-TypeRefinement-test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ describe('missing data detection with feature ENABLE_PRECISE_TYPE_REFINEMENT', (
131131
function commitPayload(operation, payload) {
132132
environment.retain(operation);
133133
environment.commitPayload(operation, payload);
134-
(environment.getStore(): $FlowFixMe).__gc();
134+
(environment.getStore(): $FlowFixMe).scheduleGC();
135+
jest.runAllTimers();
135136
}
136137

137138
it('concrete spread on matching concrete type reads data and counts missing user fields as missing', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.