| 94 | } |
| 95 | |
| 96 | void Context::onDestroy() { |
| 97 | Ref<ContextHandler> handler; |
| 98 | std::vector<Ref<ValueFunction>> updateCompletedCallbacks; |
| 99 | std::deque<PendingRenderRequest> pendingRenderRequests; |
| 100 | Ref<Metrics> metrics; |
| 101 | auto notifySync = false; |
| 102 | |
| 103 | { |
| 104 | std::unique_lock<Mutex> lock(_mutex); |
| 105 | if (_destroyed) { |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | _destroyed = true; |
| 110 | _componentContext = nullptr; |
| 111 | handler = std::move(_handler); |
| 112 | _viewModel = nullptr; |
| 113 | if (_runtime != nullptr) { |
| 114 | metrics = _runtime->getMetrics(); |
| 115 | _runtime = nullptr; |
| 116 | } |
| 117 | updateCompletedCallbacks = std::move(_updateCompletedCallbacks); |
| 118 | // NOTE(rjaber): The pending render request can contain a disposable, which will request access to the lock |
| 119 | pendingRenderRequests = std::move(_pendingRenderRequests); |
| 120 | notifySync = _updateHandlerSynchronously; |
| 121 | } |
| 122 | |
| 123 | if (handler != nullptr) { |
| 124 | auto sessionTime = _creationWatch.elapsed(); |
| 125 | if (metrics != nullptr) { |
| 126 | metrics->emitSessionTime(getPath().getResourceId().bundleName, sessionTime); |
| 127 | } |
| 128 | |
| 129 | handler->onDestroy(strongSmallRef(this), notifySync); |
| 130 | } |
| 131 | |
| 132 | callUpdateCompletedCallbacks(updateCompletedCallbacks); |
| 133 | releaseDisposables(); |
| 134 | } |
| 135 | |
| 136 | void Context::onRendered() { |
| 137 | if (_didPerformInitialRender) { |
nothing calls this directly
no test coverage detected