MCPcopy Create free account
hub / github.com/devosoft/avida / KillThread

Method KillThread

avida-core/source/cpu/cHardwareCPU.cc:1592–1616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1590}
1591
1592bool 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...

Callers

nothing calls this directly

Calls 3

GetSizeMethod · 0.45
GetIDMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected