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

Method onDestroy

valdi/src/valdi/runtime/Context/Context.cpp:96–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void 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
136void Context::onRendered() {
137 if (_didPerformInitialRender) {

Callers

nothing calls this directly

Calls 6

strongSmallRefFunction · 0.85
emitSessionTimeMethod · 0.80
getMetricsMethod · 0.65
onDestroyMethod · 0.65
elapsedMethod · 0.45

Tested by

no test coverage detected