| 298 | return _viewNodeManager.createViewNodeTreeForContext(context, threadAffinity); |
| 299 | } |
| 300 | |
| 301 | SharedViewNodeTree 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 | |
| 317 | void Runtime::destroyContext(const SharedContext& context) { |
no test coverage detected