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

Callers 1

getViewNodeTreeFunction · 0.80

Calls 3

getContextMethod · 0.45

Tested by

no test coverage detected