MCPcopy Create free account
hub / github.com/DFHack/dfhack / Update

Method Update

library/Core.cpp:1619–1655  ·  view source on GitHub ↗

should always be from simulation thread!

Source from the content-addressed store, hash-verified

1617
1618// should always be from simulation thread!
1619int Core::Update()
1620{
1621 if (shutdown)
1622 {
1623 // release the suspender
1624 MainThread::suspend().unlock();
1625 return -1;
1626 }
1627
1628 if(errorstate)
1629 return -1;
1630
1631 color_ostream_proxy out(con);
1632
1633 // Pretend this thread has suspended the core in the usual way,
1634 // and run various processing hooks.
1635 {
1636 if(!started)
1637 {
1638 // Initialize the core
1639 InitSimulationThread();
1640 if(errorstate)
1641 return -1;
1642 }
1643
1644 uint32_t start_ms = p->getTickCount();
1645 unpaused_ms += perf_counters.registerTick(start_ms);
1646 doUpdate(out);
1647 perf_counters.incCounter(perf_counters.total_update_ms, start_ms);
1648 }
1649
1650 // Let all commands run that require CoreSuspender
1651 CoreWakeup.wait(MainThread::suspend(),
1652 [this]() -> bool {return this->toolCount.load() == 0;});
1653
1654 return 0;
1655};
1656
1657extern bool buildings_do_onupdate;
1658void buildings_onStateChange(color_ostream &out, state_change_event event);

Callers 1

dfhooks_updateFunction · 0.80

Calls 6

getTickCountMethod · 0.80
incCounterMethod · 0.80
waitMethod · 0.80
unlockMethod · 0.45
registerTickMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected