MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / Run

Method Run

DebugView++Lib/ProcessMonitor.cpp:51–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void ProcessMonitor::Run()
52{
53 int offset = 0;
54 while (!m_end)
55 {
56 std::array<HANDLE, MAXIMUM_WAIT_OBJECTS> handles;
57 handles[0] = m_event.get();
58 int processCount = m_processes.size();
59 int count = std::min(processCount, MAXIMUM_WAIT_OBJECTS - 1);
60 for (int i = 0; i < count; ++i)
61 handles[i + 1] = m_processes[(offset + i) % processCount].handle;
62 DWORD timeout = static_cast<size_t>(count) < m_processes.size() ? 1000 : INFINITE;
63 auto result = Win32::WaitForAnyObject(handles.data(), handles.data() + count + 1, timeout);
64 if (!result.signaled)
65 {
66 offset = (offset + count) % processCount;
67 }
68 else if (result.index == 0)
69 {
70 while (!m_q.Empty())
71 m_q.Pop()();
72 }
73 else
74 {
75 int i = (offset + result.index - 1) % processCount;
76 m_processEnded(m_processes[i].pid, m_processes[i].handle);
77 m_processes[i] = m_processes.back();
78 m_processes.resize(processCount - 1);
79 }
80 }
81}
82
83} // namespace debugviewpp
84} // namespace fusion

Callers

nothing calls this directly

Calls 6

dataMethod · 0.80
resizeMethod · 0.80
WaitForAnyObjectFunction · 0.50
sizeMethod · 0.45
EmptyMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected