Skip to content

Commit

Permalink
Platform: Core: assert when attempting to start an already running th…
Browse files Browse the repository at this point in the history
…read.
  • Loading branch information
fleroviux committed Jan 14, 2024
1 parent 934e88f commit db6802f
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/platform/core/src/emulator_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,32 @@ void EmulatorThread::SetPerFrameCallback(std::function<void()> callback) {
}

void EmulatorThread::Start(std::unique_ptr<CoreBase> core) {
this->core = std::move(core);
Assert(!running, "Started an emulator thread which was already running");

if(!running) {
running = true;
thread = std::thread{[this]() {
frame_limiter.Reset();

while(running.load()) {
ProcessMessages();

frame_limiter.Run([this]() {
if(!paused) {
// @todo: decide what to do with the per_frame_cb().
per_frame_cb();
this->core->Run(k_cycles_per_subsample);
}
}, [this](float fps) {
float real_fps = fps / k_input_subsample_count;
if(paused) {
real_fps = 0;
}
frame_rate_cb(real_fps);
});
}
}};
}
this->core = std::move(core);
running = true;

thread = std::thread{[this]() {
frame_limiter.Reset();

while(running.load()) {
ProcessMessages();

frame_limiter.Run([this]() {
if(!paused) {
// @todo: decide what to do with the per_frame_cb().
per_frame_cb();
this->core->Run(k_cycles_per_subsample);
}
}, [this](float fps) {
float real_fps = fps / k_input_subsample_count;
if(paused) {
real_fps = 0;
}
frame_rate_cb(real_fps);
});
}
}};
}

std::unique_ptr<CoreBase> EmulatorThread::Stop() {
Expand Down

0 comments on commit db6802f

Please sign in to comment.