| 403 | } |
| 404 | |
| 405 | void MockPresentMonSession::Output() { |
| 406 | // Structures to track processes and statistics from recorded events. |
| 407 | std::vector<ProcessEvent> processEvents; |
| 408 | std::vector<std::shared_ptr<PresentEvent>> presentEvents; |
| 409 | std::vector<std::pair<uint32_t, uint64_t>> terminatedProcesses; |
| 410 | processEvents.reserve(128); |
| 411 | presentEvents.reserve(4096); |
| 412 | terminatedProcesses.reserve(16); |
| 413 | |
| 414 | for (;;) { |
| 415 | // Read quit_output_thread_ here, but then check it after processing |
| 416 | // queued events. This ensures that we call DequeueAnalyzedInfo() at |
| 417 | // least once after events have stopped being collected so that all |
| 418 | // events are included. |
| 419 | const auto quit = quit_output_thread_.load(); |
| 420 | |
| 421 | // Copy and process all the collected events, and update the various |
| 422 | // tracking and statistics data structures. |
| 423 | ProcessEvents(&processEvents, &presentEvents, &terminatedProcesses); |
| 424 | |
| 425 | // Everything is processed and output out at this point, so if we're |
| 426 | // quiting we don't need to update the rest. |
| 427 | if (quit) { |
| 428 | break; |
| 429 | } |
| 430 | |
| 431 | // Sleep to reduce overhead. |
| 432 | // TODO: sync this to eliminate overhead / lag |
| 433 | std::this_thread::sleep_for(10ms); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | void MockPresentMonSession::StartOutputThread() { |
| 438 | quit_output_thread_ = false; |
nothing calls this directly
no test coverage detected