Skip to content

Commit

Permalink
feat: mark _scheduleGC public by renaming it to scheduleGC. (#3167)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
n1ru4l authored and facebook-github-bot committed Nov 12, 2020
1 parent ceb19d6 commit 97401cb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/relay-runtime/store/RelayModernStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class RelayModernStore implements Store {

if (rootEntryIsStale) {
this._roots.delete(id);
this._scheduleGC();
this.scheduleGC();
} else {
this._releaseBuffer.push(id);

Expand All @@ -243,7 +243,7 @@ class RelayModernStore implements Store {
if (this._releaseBuffer.length > this._gcReleaseBufferSize) {
const _id = this._releaseBuffer.shift();
this._roots.delete(_id);
this._scheduleGC();
this.scheduleGC();
}
}
}
Expand Down Expand Up @@ -413,7 +413,7 @@ class RelayModernStore implements Store {
if (this._gcHoldCounter > 0) {
this._gcHoldCounter--;
if (this._gcHoldCounter === 0 && this._shouldScheduleGC) {
this._scheduleGC();
this.scheduleGC();
this._shouldScheduleGC = false;
}
}
Expand Down Expand Up @@ -592,7 +592,7 @@ class RelayModernStore implements Store {
}
this._optimisticSource = null;
if (this._shouldScheduleGC) {
this._scheduleGC();
this.scheduleGC();
}
this._subscriptions.forEach(subscription => {
const backup = subscription.backup;
Expand All @@ -614,7 +614,7 @@ class RelayModernStore implements Store {
});
}

_scheduleGC() {
scheduleGC() {
if (this._gcHoldCounter > 0) {
this._shouldScheduleGC = true;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ describe('execute() with Flight field', () => {
expect(complete).toBeCalledTimes(0);
expect(error).toBeCalledTimes(0);
expect(reactFlightPayloadDeserializer).toBeCalledTimes(1);
store.__gc();

store.scheduleGC();
jest.runAllTimers();

expect(environment.lookup(innerOperation.fragment).data).toEqual({
node: {
name: 'Lauren',
Expand Down Expand Up @@ -259,7 +262,10 @@ describe('execute() with Flight field', () => {
expect(complete).toBeCalledTimes(0);
expect(error).toBeCalledTimes(0);
expect(reactFlightPayloadDeserializer).toBeCalledTimes(1);
store.__gc(); // Invoke gc to verify that data is retained

store.scheduleGC(); // Invoke gc to verify that data is retained
jest.runAllTimers();

expect(environment.lookup(innerOperation.fragment).data).toEqual({
node: {
name: 'Lauren',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ describe('execute() fetches a @stream-ed @connection', () => {
callback.mockClear();

// Triggers a GC
store.__gc();
store.scheduleGC();
jest.runAllTimers();

// Second edge should be appended correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ describe('missing data detection with feature ENABLE_PRECISE_TYPE_REFINEMENT', (
function commitPayload(operation, payload) {
environment.retain(operation);
environment.commitPayload(operation, payload);
(environment.getStore(): $FlowFixMe).__gc();
(environment.getStore(): $FlowFixMe).scheduleGC();
jest.runAllTimers();
}

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

0 comments on commit 97401cb

Please sign in to comment.