2011-01-03 04:28:36 +00:00
|
|
|
#include <gameboy/gameboy.hpp>
|
2010-12-28 06:03:02 +00:00
|
|
|
|
|
|
|
#define SCHEDULER_CPP
|
|
|
|
namespace GameBoy {
|
|
|
|
|
|
|
|
Scheduler scheduler;
|
|
|
|
|
|
|
|
void Scheduler::enter() {
|
|
|
|
host_thread = co_active();
|
|
|
|
co_switch(active_thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scheduler::exit() {
|
|
|
|
active_thread = co_active();
|
|
|
|
co_switch(host_thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scheduler::swapto(Processor &p) {
|
|
|
|
active_thread = p.thread;
|
|
|
|
co_switch(active_thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scheduler::init() {
|
|
|
|
host_thread = co_active();
|
|
|
|
active_thread = cpu.thread;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scheduler::Scheduler() {
|
|
|
|
host_thread = 0;
|
|
|
|
active_thread = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|