I did forget one thing. One the m_PendingJobs map becomes empty I have to make sure to empty the m_JobKeys deque

The proper code at the completion of a job is
PHP Code:
if (wParam != m_PendingJobs.size() - 1)
    
m_JobKeys.push_back(wParam);
m_PendingJobs.erase(m_PendingJobs.find(wParam));
if (
m_PendingJobs.empty())
    
m_JobKeys.clear();