Fabric: Assert on destruction non-empty of ShadowTreeRegistry

Summary:
Destruction of Scheduler (and ShadowTreeRegistry as part of it) which has some running Surfaces is not a good thing and practically a bug on the application layer.
With this assert we throw early to flag the issue.

Changelog: [Internal] - Dev only assert indicating a broken invariant in ShadowTreeRegistry

Reviewed By: sammy-SC

Differential Revision: D17924491

fbshipit-source-id: 6b7433fe47630e993e7d5b969f3113f96124b6c9
This commit is contained in:
Valentin Shergin
2019-10-15 07:55:00 -07:00
committed by Facebook Github Bot
parent e7ef9921d3
commit 8bce9c59bb
2 changed files with 5 additions and 0 deletions
@@ -8,6 +8,10 @@
namespace facebook {
namespace react {
ShadowTreeRegistry::~ShadowTreeRegistry() {
assert(registry_.size() == 0 && "Deallocation of non-empty `ShadowTreeRegistry`.");
}
void ShadowTreeRegistry::add(std::unique_ptr<ShadowTree> &&shadowTree) const {
std::unique_lock<better::shared_mutex> lock(mutex_);
@@ -19,6 +19,7 @@ namespace react {
class ShadowTreeRegistry final {
public:
ShadowTreeRegistry() = default;
~ShadowTreeRegistry();
/*
* Adds a `ShadowTree` instance to the registry.