Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/gameboy/scheduler/scheduler.cpp
2 views
1
#include <gameboy/gameboy.hpp>
2
3
#define SCHEDULER_CPP
4
namespace GameBoy {
5
6
Scheduler scheduler;
7
8
void Scheduler::enter() {
9
host_thread = co_active();
10
co_switch(active_thread);
11
}
12
13
void Scheduler::exit(ExitReason reason) {
14
exit_reason = reason;
15
active_thread = co_active();
16
co_switch(host_thread);
17
}
18
19
void Scheduler::swapto(Processor &p) {
20
active_thread = p.thread;
21
co_switch(active_thread);
22
}
23
24
void Scheduler::init() {
25
host_thread = co_active();
26
active_thread = cpu.thread;
27
}
28
29
Scheduler::Scheduler() {
30
exit_reason = ExitReason::UnknownEvent;
31
host_thread = 0;
32
active_thread = 0;
33
}
34
35
}
36
37