mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-22 06:02:28 +01:00
byuu says: I refactored my schedulers. Added about ten lines to each scheduler, and removed about 100 lines of calling into internal state in the scheduler for the FC,SFC cores and about 30-40 lines for the other cores. All of its state is now private. Also reworked all of the entry points to static auto Enter() and auto main(). Where Enter() handles all the synchronization stuff, and main() doesn't need the while(true); loop forcing another layer of indentation everywhere. Took a few hours to do, but totally worth it. I'm surprised I didn't do this sooner. Also updated icarus gmake install rule to copy over the database.
30 lines
732 B
C++
30 lines
732 B
C++
struct Scheduler {
|
|
enum class Mode : uint {
|
|
Run,
|
|
SynchronizeCPU,
|
|
SynchronizeAll,
|
|
};
|
|
|
|
enum class Event : uint {
|
|
Unknown,
|
|
Frame,
|
|
Synchronize,
|
|
Debugger,
|
|
};
|
|
|
|
auto reset() -> void;
|
|
auto enter(Mode = Mode::Run) -> Event;
|
|
auto exit(Event) -> void;
|
|
auto synchronize(cothread_t) -> void;
|
|
auto synchronize() -> void;
|
|
auto synchronizing() const -> bool;
|
|
|
|
private:
|
|
cothread_t host = nullptr; //program thread (used to exit emulation)
|
|
cothread_t resume = nullptr; //resume thread (used to re-enter emulation)
|
|
Mode mode = Mode::Run; //determines when to exit emulation thread
|
|
Event event = Event::Unknown; //set by exit(), returned by enter()
|
|
};
|
|
|
|
extern Scheduler scheduler;
|