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

Method resolveViewNodeTree

valdi/src/valdi/runtime/Runtime.cpp:713–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711 auto context = _contextManager.getContext(contextId);
712 if (context == nullptr) {
713 VALDI_WARN(*_logger, "Cannot call action: Context {} was already destroyed.", contextId);
714 return;
715 }
716 auto viewNodeTree = _viewNodeManager.getViewNodeTreeForContextId(context->getContextId());
717 if (viewNodeTree == nullptr) {
718 VALDI_WARN(*_logger, "Cannot call action: no ViewNodeTree associated with context {}", context->getContextId());
719 return;
720 }
721
722 context->getViewManagerContext()->getViewManager().callAction(viewNodeTree.get(), actionName, parameters);
723}
724
725void Runtime::resolveViewNodeTree(const SharedContext& context,
726 bool inMainThread,
727 bool createIfNeeded,
728 Function<void(const SharedViewNodeTree&)>&& function) {
729 Ref<ViewNodeTree> viewNodeTree;
730 if (createIfNeeded) {
731 viewNodeTree =
732 _viewNodeManager.getOrCreateViewNodeTreeForContext(context, ViewNodeTreeThreadAffinity::MAIN_THREAD);
733 } else {
734 viewNodeTree = _viewNodeManager.getViewNodeTreeForContextId(context->getContextId());
735 }
736
737 DispatchFunction dispatchFn = [viewNodeTree, function = std::move(function)]() {
738 auto lock = viewNodeTree != nullptr ? viewNodeTree->lock() : TrackedLock();

Calls 7

TrackedLockClass · 0.85
getContextIdMethod · 0.45
lockMethod · 0.45
dispatchMethod · 0.45

Tested by

no test coverage detected