MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / ThreadProcedure_

Method ThreadProcedure_

IntelPresentMon/Core/source/kernel/Kernel.cpp:166–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164 }
165
166 void Kernel::ThreadProcedure_()
167 {
168 try {
169 // mutex that prevents frontend from accessing before pmon is connected
170 std::unique_lock startLck{ mtx };
171
172 // name this thread
173 pmlog_info("== kernel thread starting ==");
174
175 // command line options
176 auto& opt = cli::Options::Get();
177
178 // connect to wbem
179 ::pmon::util::win::com::WbemConnection wbemConn;
180
181 // connection names control from cli override / svc-as-child
182 auto controlPipe = opt.controlPipe.AsOptional();
183 // force optionals filled with default values if not specified when launching service as child
184 if (opt.svcAsChild) {
185 controlPipe = *opt.controlPipe;
186 }
187
188 // create the PresentMon object
189 try { pm.emplace(controlPipe); }
190 catch (...) {
191 pHandler->OnPresentmonInitFailed();
192 pmlog_error("Failed to init presentmon api").no_trace();
193 throw;
194 }
195
196 startLck.unlock();
197 constructionSemaphore.release();
198
199 while (!dying)
200 {
201 try
202 {
203 {
204 std::unique_lock u{ mtx };
205 cv.wait(u, [this] {return !IsIdle_(); });
206 }
207 if (pPushedSpec && !dying)
208 {
209 // spawn overlay (container)
210 ConfigurePresentMon_(*pPushedSpec);
211 pOverlayContainer = std::make_unique<OverlayContainer>(wbemConn, std::move(pPushedSpec), &*pm, headless);
212 }
213 if (pOverlayContainer && !dying)
214 {
215 // blocks while overlay is active
216 RunOverlayLoop_();
217 }
218 }
219 // this catch section handles target lost and overlay crashes
220 // control app will still work, can attempt to instance another overlay
221 catch (const TargetLostException&)
222 {
223 if (pOverlayContainer) {

Callers

nothing calls this directly

Calls 8

ReportExceptionFunction · 0.85
GetDefaultChannelFunction · 0.50
AsOptionalMethod · 0.45
OnTargetLostMethod · 0.45
OnStalePidSelectedMethod · 0.45
OnOverlayDiedMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected