| 1590 | } |
| 1591 | |
| 1592 | bool cHardwareCPU::KillThread() |
| 1593 | { |
| 1594 | // Make sure that there is always at least one thread... |
| 1595 | if (m_threads.GetSize() == 1) return false; |
| 1596 | |
| 1597 | // Note the current thread and set the current back one. |
| 1598 | const int kill_thread = m_cur_thread; |
| 1599 | ThreadPrev(); |
| 1600 | |
| 1601 | // Turn off this bit in the m_thread_id_chart... |
| 1602 | m_thread_id_chart ^= 1 << m_threads[kill_thread].GetID(); |
| 1603 | |
| 1604 | // Copy the last thread into the kill position |
| 1605 | const int last_thread = m_threads.GetSize() - 1; |
| 1606 | if (last_thread != kill_thread) { |
| 1607 | m_threads[kill_thread] = m_threads[last_thread]; |
| 1608 | } |
| 1609 | |
| 1610 | // Kill the thread! |
| 1611 | m_threads.Resize(m_threads.GetSize() - 1); |
| 1612 | |
| 1613 | if (m_cur_thread > kill_thread) m_cur_thread--; |
| 1614 | |
| 1615 | return true; |
| 1616 | } |
| 1617 | |
| 1618 | //////////////////////////// |
| 1619 | // Instruction Helpers... |