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

Method getOrCreateViewNodeTreeForContextId

valdi/src/valdi/runtime/Runtime.cpp:300–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298
299SharedViewNodeTree Runtime::createViewNodeTree(const SharedContext& context,
300 ViewNodeTreeThreadAffinity threadAffinity) {
301 return _viewNodeManager.createViewNodeTreeForContext(context, threadAffinity);
302}
303
304SharedViewNodeTree Runtime::getOrCreateViewNodeTreeForContextId(ContextId contextId) {
305 auto tree = _viewNodeManager.getViewNodeTreeForContextId(contextId);
306 if (tree != nullptr) {
307 return tree;
308 }
309
310 auto context = _contextManager->getContext(contextId);
311 if (context == nullptr) {
312 return nullptr;
313 }
314
315 // Use the thread-safe getOrCreateViewNodeTreeForContext which holds the lock
316 // during both the existence check and creation to avoid TOCTOU race conditions.
317 return _viewNodeManager.getOrCreateViewNodeTreeForContext(context, ViewNodeTreeThreadAffinity::MAIN_THREAD);

Callers 1

getViewNodeTreeFunction · 0.80

Calls 3

getContextMethod · 0.45

Tested by

no test coverage detected