Reduce visibility of ReactChoreographer.postFrameCallbackOnChoreographer method

Summary: The method ReactChoreographer.postFrameCallbackOnChoreographer should be private and it should be called from a context that contains the lock mCallbackQueuesLock

Reviewed By: JoshuaGross

Differential Revision: D15891758

fbshipit-source-id: fedba0db663aade25dbad1ef7151df1e340e05f6
This commit is contained in:
David Vacca
2019-06-24 19:08:39 -07:00
committed by Facebook Github Bot
parent 89bf3d8b38
commit beee546779
@@ -14,6 +14,7 @@ import javax.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.common.ReactConstants;
import javax.annotation.concurrent.GuardedBy;
/**
* A simple wrapper around Choreographer that allows us to control the order certain callbacks
@@ -78,8 +79,9 @@ public class ReactChoreographer {
// This needs to be volatile due to double checked locking issue - https://fburl.com/z409owpf
private @Nullable volatile ChoreographerCompat mChoreographer;
private final ReactChoreographerDispatcher mReactChoreographerDispatcher;
private final ArrayDeque<ChoreographerCompat.FrameCallback>[] mCallbackQueues;
private final Object mCallbackQueuesLock = new Object();
@GuardedBy("mCallbackQueuesLock")
private final ArrayDeque<ChoreographerCompat.FrameCallback>[] mCallbackQueues;
private int mTotalCallbacks = 0;
private boolean mHasPostedCallback = false;
@@ -116,7 +118,11 @@ public class ReactChoreographer {
}
}
public void postFrameCallbackOnChoreographer() {
/**
* This method writes on mHasPostedCallback and it should be called from another method that
* has the lock mCallbackQueuesLock
*/
private void postFrameCallbackOnChoreographer() {
mChoreographer.postFrameCallback(mReactChoreographerDispatcher);
mHasPostedCallback = true;
}
@@ -150,6 +156,10 @@ public class ReactChoreographer {
}
}
/**
* This method reads and writes on mHasPostedCallback and it should be called from another method
* that already has the lock mCallbackQueuesLock.
*/
private void maybeRemoveFrameCallback() {
Assertions.assertCondition(mTotalCallbacks >= 0);
if (mTotalCallbacks == 0 && mHasPostedCallback) {