timer.cc

来自「一个mips虚拟机非常好代码,使用C++来编写的,希望大家多学学,」· CC 代码 · 共 43 行

CC
43
字号
#include "koala.hh"SerialType<Koala::Timer> Koala::Timer::type(    "Koala::Timer");Koala::Timer::Timer(Checkpoint& cp)    : Serializable(cp), Event(cp){    SerialID cid = extract<SerialID>(cp);    cpu = dynamic_cast<Koala *>(find_object(cid));    if (!cpu)	throw Checkpoint::SyntaxError(cp, "%d is not a Koala module ID", cid);}voidKoala::Timer::invoke(){    cpu->deliver_interrupt(5);}voidKoala::Timer::checkpoint(Checkpoint& cp, bool parent) const{    if (parent)	cp << type << ' ' << id << '\n';    Event::checkpoint(cp);    cp << cpu->id << '\n';}voidKoala::set_timer(){    if (timer != NULL)    {	remove(timer);	delete timer;    }    timer = new Timer(this, now + (cp0[Compare] - (cp0[Count] + ((now - count_seed) / 2))) * 2);    insert(timer);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?