| 193 | } |
| 194 | |
| 195 | void CProcessThreadTable::Refresh() { |
| 196 | auto first = m_Table.data.info.empty(); |
| 197 | m_ProcMgr.EnumProcessAndThreads(m_Pid); |
| 198 | auto count = (int)m_ProcMgr.GetThreadCount(); |
| 199 | |
| 200 | if (first) { |
| 201 | m_Table.data.info = m_ProcMgr.GetThreads(); |
| 202 | m_Table.data.n = count; |
| 203 | m_TermThreads.reserve(32); |
| 204 | m_NewThreads.reserve(32); |
| 205 | return; |
| 206 | } |
| 207 | |
| 208 | auto tick = ::GetTickCount64(); |
| 209 | count = (int)m_Table.data.info.size(); |
| 210 | for (int i = 0; i < count; i++) { |
| 211 | auto& t = m_Table.data.info[i]; |
| 212 | auto& tx = GetThreadInfoEx(t.get()); |
| 213 | if (tx.IsTerminated && tick > tx.TargetTime) { |
| 214 | m_ThreadsEx.erase(t.get()); |
| 215 | m_Table.data.info.erase(m_Table.data.info.begin() + i); |
| 216 | i--; |
| 217 | count--; |
| 218 | continue; |
| 219 | } |
| 220 | if (tx.IsNew && tick > tx.TargetTime) { |
| 221 | tx.IsNew = false; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | count = (int)m_TermThreads.size(); |
| 226 | tick = ::GetTickCount64(); |
| 227 | |
| 228 | for (int i = 0; i < count; i++) { |
| 229 | auto& t = m_TermThreads[i]; |
| 230 | auto& tx = GetThreadInfoEx(t.get()); |
| 231 | if (tick > tx.TargetTime) { |
| 232 | tx.IsTerminated = true; |
| 233 | m_TermThreads.erase(m_TermThreads.begin() + i); |
| 234 | i--; |
| 235 | count--; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | count = (int)m_NewThreads.size(); |
| 240 | for (int i = 0; i < count; i++) { |
| 241 | auto& t = m_NewThreads[i]; |
| 242 | auto& tx = GetThreadInfoEx(t.get()); |
| 243 | if (tick > tx.TargetTime) { |
| 244 | tx.IsNew = false; |
| 245 | m_NewThreads.erase(m_NewThreads.begin() + i); |
| 246 | i--; |
| 247 | count--; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | for (auto& t : m_ProcMgr.GetTerminatedThreads()) { |
| 252 | auto& tx = GetThreadInfoEx(t.get()); |
nothing calls this directly
no test coverage detected