Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store last reanimated root as atomic ptr, avoid copying and locking #4813

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Common/cpp/Fabric/PropsRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ class PropsRegistry {

void setLastReanimatedRoot(
RootShadowNode::Shared const &lastReanimatedRoot) noexcept {
// TODO: synchronize with mutex?
lastReanimatedRoot_ = lastReanimatedRoot;
lastReanimatedRoot_.store(lastReanimatedRoot.get());
}

bool isLastReanimatedRoot(
RootShadowNode::Shared const &newRootShadowNode) const noexcept {
// TODO: synchronize with mutex?
return newRootShadowNode == lastReanimatedRoot_;
return newRootShadowNode.get() == lastReanimatedRoot_.load();
}

void pleaseSkipCommit() {
Expand All @@ -50,7 +48,7 @@ class PropsRegistry {

mutable std::mutex mutex_; // Protects `map_`.

RootShadowNode::Shared lastReanimatedRoot_;
std::atomic<const RootShadowNode *> lastReanimatedRoot_;

std::atomic<bool> letMeIn_;
};
Expand Down