| 6 | static std::thread gThread; |
| 7 | |
| 8 | static void Consume(TRACEHANDLE traceHandle) |
| 9 | { |
| 10 | SetThreadDescription(GetCurrentThread(), L"PresentMon Consumer Thread"); |
| 11 | SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); |
| 12 | |
| 13 | // You must call OpenTrace() prior to calling this function |
| 14 | // |
| 15 | // ProcessTrace() blocks the calling thread until it |
| 16 | // 1) delivers all events in a trace log file, or |
| 17 | // 2) the BufferCallback function returns FALSE, or |
| 18 | // 3) you call CloseTrace(), or |
| 19 | // 4) the controller stops the trace session. |
| 20 | // |
| 21 | // There may be a several second delay before the function returns. |
| 22 | // |
| 23 | // ProcessTrace() is supposed to return ERROR_CANCELLED if BufferCallback |
| 24 | // (EtwThreadsShouldQuit) returns FALSE; and ERROR_SUCCESS if the trace |
| 25 | // completes (parses the entire ETL, fills the maximum file size, or is |
| 26 | // explicitly closed). |
| 27 | // |
| 28 | // However, it seems to always return ERROR_SUCCESS. |
| 29 | |
| 30 | auto status = ProcessTrace(&traceHandle, 1, NULL, NULL); |
| 31 | (void) status; |
| 32 | |
| 33 | // Signal MainThread to exit. This is only needed if we are processing an |
| 34 | // ETL file and ProcessTrace() returned because the ETL is done, but there |
| 35 | // is no harm in calling ExitMainThread() if MainThread is already exiting |
| 36 | // (and caused ProcessTrace() to exit via 2, 3, or 4 above) because the |
| 37 | // message queue isn't beeing listened too anymore in that case. |
| 38 | ExitMainThread(); |
| 39 | } |
| 40 | |
| 41 | void StartConsumerThread(TRACEHANDLE traceHandle) |
| 42 | { |
no test coverage detected