MCPcopy Create free account
hub / github.com/Snapchat/Valdi / runUpdatesInner

Method runUpdatesInner

valdi/src/valdi/runtime/Context/ViewNodeTree.cpp:744–820  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742 TrackedLock guard(_mutex, deadline);
743 if (!guard.owns()) {
744 return false;
745 }
746 ContextEntry contextEntry(_context);
747 _context->withAttribution([&]() {
748 auto viewTransationScope = beginViewTransaction();
749 fn();
750 endViewTransaction(viewTransationScope, /* layoutDidBecomeDirty */ false);
751 });
752 return true;
753}
754
755void ViewNodeTree::runUpdates() {
756 if (_updateFunctions.empty()) {
757 return;
758 }
759
760 _context->withAttribution([&]() { runUpdatesInner(); });
761}
762
763void ViewNodeTree::runUpdatesInner() {
764 const auto runUpdatesStart = std::chrono::steady_clock::now();
765 if (!_runUpdatesInnerSessionStart.has_value()) {
766 _runUpdatesInnerSessionStart = runUpdatesStart;
767 }
768
769 ContextEntry contextEntry(_context);
770 auto viewTransactionScope = beginViewTransaction();
771
772 auto layoutDirtyCounter = _layoutDirtyCounter;
773 _updating = true;
774 SmallVector<DispatchFunction, 4> completions;
775
776 Ref<AssetsManager> assetsManager;
777 if (_runtime != nullptr) {
778 assetsManager = _runtime->getResourceManager().getAssetsManager();
779 assetsManager->beginPauseUpdates();
780 }
781
782#if !VALDI_DEBUG_TREE_UPDATES
783 VALDI_TRACE("Valdi.runTreeUpdates");
784#endif
785
786 while (!_updateFunctions.empty()) {
787 auto updates = std::move(_updateFunctions.front());
788 _updateFunctions.pop_front();
789
790#if VALDI_DEBUG_TREE_UPDATES
791 // Emit trace per update with component name (symbol only) and trigger.
792 std::string traceSuffix;
793 if (!_context->getPath().isEmpty()) {
794 const auto& path = _context->getPath();
795 traceSuffix = path.getSymbolName().isEmpty() ? path.toString() : path.getSymbolName().slowToString();
796 }
797 if (!updates.traceTrigger.empty()) {
798 if (!traceSuffix.empty()) {
799 traceSuffix += "|";
800 }
801 traceSuffix += updates.traceTrigger;

Callers

nothing calls this directly

Calls 14

beginPauseUpdatesMethod · 0.80
frontMethod · 0.80
slowToStringMethod · 0.80
flushUpdatesMethod · 0.80
endPauseUpdatesMethod · 0.80
toStringMethod · 0.65
nowFunction · 0.50
has_valueMethod · 0.45
getAssetsManagerMethod · 0.45
emptyMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected