mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 10:34:57 +00:00
Fabric: ShadowTree is now stored as unique_ptr instead of shared_ptr
Summary: @public Now it's clear that we don't need to store/handle ShadowTree objects as `shared_ptr`s; Scheduler should own it. This diff changes that to using unique_ptr and removes a base class of ShadowTree. Reviewed By: mdvacca Differential Revision: D9403567 fbshipit-source-id: 6e411714b632a04233fd5b25c8ab7cdd260105fd
This commit is contained in:
parent
1068da2ec7
commit
294d91b30a
@ -45,9 +45,9 @@ Scheduler::~Scheduler() {
|
||||
}
|
||||
|
||||
void Scheduler::registerRootTag(Tag rootTag) {
|
||||
const auto &shadowTree = std::make_shared<ShadowTree>(rootTag);
|
||||
auto shadowTree = std::make_unique<ShadowTree>(rootTag);
|
||||
shadowTree->setDelegate(this);
|
||||
shadowTreeRegistry_.insert({rootTag, shadowTree});
|
||||
shadowTreeRegistry_.emplace(rootTag, std::move(shadowTree));
|
||||
}
|
||||
|
||||
void Scheduler::unregisterRootTag(Tag rootTag) {
|
||||
@ -82,9 +82,9 @@ SchedulerDelegate *Scheduler::getDelegate() const {
|
||||
|
||||
#pragma mark - ShadowTreeDelegate
|
||||
|
||||
void Scheduler::shadowTreeDidCommit(const SharedShadowTree &shadowTree, const ShadowViewMutationList &mutations) {
|
||||
void Scheduler::shadowTreeDidCommit(const ShadowTree &shadowTree, const ShadowViewMutationList &mutations) {
|
||||
if (delegate_) {
|
||||
delegate_->schedulerDidFinishTransaction(shadowTree->getRootTag(), mutations);
|
||||
delegate_->schedulerDidFinishTransaction(shadowTree.getRootTag(), mutations);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
#pragma mark - ShadowTreeDelegate
|
||||
|
||||
void shadowTreeDidCommit(const SharedShadowTree &shadowTree, const ShadowViewMutationList &mutations) override;
|
||||
void shadowTreeDidCommit(const ShadowTree &shadowTree, const ShadowViewMutationList &mutations) override;
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
@ -69,7 +69,7 @@ public:
|
||||
private:
|
||||
SchedulerDelegate *delegate_;
|
||||
std::shared_ptr<FabricUIManager> uiManager_;
|
||||
std::unordered_map<Tag, SharedShadowTree> shadowTreeRegistry_;
|
||||
std::unordered_map<Tag, std::unique_ptr<ShadowTree>> shadowTreeRegistry_;
|
||||
SharedEventDispatcher eventDispatcher_;
|
||||
SharedContextContainer contextContainer_;
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ void ShadowTree::complete(UnsharedRootShadowNode newRootShadowNode) {
|
||||
emitLayoutEvents(mutations);
|
||||
|
||||
if (delegate_) {
|
||||
delegate_->shadowTreeDidCommit(shared_from_this(), mutations);
|
||||
delegate_->shadowTreeDidCommit(*this, mutations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,15 +18,10 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class ShadowTree;
|
||||
|
||||
using SharedShadowTree = std::shared_ptr<ShadowTree>;
|
||||
|
||||
/*
|
||||
* Represents the shadow tree and its lifecycle.
|
||||
*/
|
||||
class ShadowTree final:
|
||||
public std::enable_shared_from_this<ShadowTree> {
|
||||
class ShadowTree final {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
/*
|
||||
* Called right after Shadow Tree commit a new state of the the tree.
|
||||
*/
|
||||
virtual void shadowTreeDidCommit(const std::shared_ptr<ShadowTree> &shadowTree, const ShadowViewMutationList &mutations) = 0;
|
||||
virtual void shadowTreeDidCommit(const ShadowTree &shadowTree, const ShadowViewMutationList &mutations) = 0;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
Loading…
x
Reference in New Issue
Block a user