mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
BackgroundExecutor: rename shouldCancel to shouldYield
Summary: Changelog: [internal] Name `shouldCancel` is misleading. It implies the commit is cancelled and doesn't happen. `shouldYield` expresses the intent better, because the commit's changes do eventually reach mounting layer but the current commit is rather yielding to the next one. Reviewed By: mdvacca Differential Revision: D26126121 fbshipit-source-id: 18988f217cbc651f0010f6e2381682bdbaed8bd4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f92cc5ba77
commit
6b1a899ef7
@@ -332,7 +332,7 @@ CommitStatus ShadowTree::tryCommit(
|
||||
auto newRootShadowNode = transaction(*oldRevision.rootShadowNode);
|
||||
|
||||
if (!newRootShadowNode ||
|
||||
(commitOptions.shouldCancel && commitOptions.shouldCancel())) {
|
||||
(commitOptions.shouldYield && commitOptions.shouldYield())) {
|
||||
return CommitStatus::Cancelled;
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ CommitStatus ShadowTree::tryCommit(
|
||||
*this, oldRootShadowNode, newRootShadowNode);
|
||||
|
||||
if (!newRootShadowNode ||
|
||||
(commitOptions.shouldCancel && commitOptions.shouldCancel())) {
|
||||
(commitOptions.shouldYield && commitOptions.shouldYield())) {
|
||||
return CommitStatus::Cancelled;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,9 +55,10 @@ class ShadowTree final {
|
||||
|
||||
struct CommitOptions {
|
||||
bool enableStateReconciliation{false};
|
||||
// Lambda called inside `tryCommit`. If false is returned, commit is
|
||||
// cancelled.
|
||||
std::function<bool()> shouldCancel;
|
||||
|
||||
// Called during `tryCommit` phase. Returning true indicates current commit
|
||||
// should yield to the next commit.
|
||||
std::function<bool()> shouldYield;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -458,15 +458,15 @@ jsi::Value UIManagerBinding::get(
|
||||
mostRecentSurfaceId = surfaceId;
|
||||
sharedUIManager->backgroundExecutor_(
|
||||
[=, eventCount = completeRootEventCounter.load()] {
|
||||
auto shouldCancel = [=]() -> bool {
|
||||
auto shouldYield = [=]() -> bool {
|
||||
// If `completeRootEventCounter` was incremented, another
|
||||
// `completeSurface` call has been scheduled and current
|
||||
// `completeSurface` should be cancelled.
|
||||
// `completeSurface` should yield to it.
|
||||
return completeRootEventCounter > eventCount &&
|
||||
mostRecentSurfaceId == surfaceId;
|
||||
};
|
||||
sharedUIManager->completeSurface(
|
||||
surfaceId, shadowNodeList, {true, shouldCancel});
|
||||
surfaceId, shadowNodeList, {true, shouldYield});
|
||||
});
|
||||
|
||||
return jsi::Value::undefined();
|
||||
|
||||
Reference in New Issue
Block a user