1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#ifdef SYSTEM_CPP
Scheduler scheduler;
void Scheduler::enter() {
host_thread = co_active();
co_switch(thread);
}
void Scheduler::exit(ExitReason reason) {
exit_reason = reason;
thread = co_active();
co_switch(host_thread);
}
void Scheduler::debug() {
exit(ExitReason::DebuggerEvent);
}
void Scheduler::init() {
host_thread = co_active();
thread = cpu.thread;
sync = SynchronizeMode::None;
}
Scheduler::Scheduler() {
host_thread = nullptr;
thread = nullptr;
exit_reason = ExitReason::UnknownEvent;
}
#endif
|