mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-25 00:07:53 -05:00
bootmanager: Use std::stop_source for stopping emulation
Use its std::stop_token to abort shader cache loading. Using std::stop_token instead of std::atomic_bool allows the usage of other utilities like std::stop_callback.
This commit is contained in:
@ -51,11 +51,11 @@ void EmuThread::run() {
|
||||
Common::SetCurrentThreadName(name.c_str());
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& gpu = system.GPU();
|
||||
auto stop_token = stop_source.get_token();
|
||||
|
||||
system.RegisterHostThread();
|
||||
|
||||
auto& gpu = system.GPU();
|
||||
|
||||
// Main process has been loaded. Make the context current to this thread and begin GPU and CPU
|
||||
// execution.
|
||||
gpu.Start();
|
||||
@ -65,7 +65,7 @@ void EmuThread::run() {
|
||||
emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
|
||||
|
||||
system.Renderer().ReadRasterizer()->LoadDiskResources(
|
||||
system.CurrentProcess()->GetTitleID(), stop_run,
|
||||
system.CurrentProcess()->GetTitleID(), stop_token,
|
||||
[this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) {
|
||||
emit LoadProgress(stage, value, total);
|
||||
});
|
||||
@ -78,7 +78,7 @@ void EmuThread::run() {
|
||||
// so that the DebugModeLeft signal can be emitted before the
|
||||
// next execution step
|
||||
bool was_active = false;
|
||||
while (!stop_run) {
|
||||
while (!stop_token.stop_requested()) {
|
||||
if (running) {
|
||||
if (was_active) {
|
||||
emit DebugModeLeft();
|
||||
@ -100,7 +100,7 @@ void EmuThread::run() {
|
||||
}
|
||||
running_guard = false;
|
||||
|
||||
if (!stop_run) {
|
||||
if (!stop_token.stop_requested()) {
|
||||
was_active = true;
|
||||
emit DebugModeEntered();
|
||||
}
|
||||
@ -108,7 +108,7 @@ void EmuThread::run() {
|
||||
UNIMPLEMENTED();
|
||||
} else {
|
||||
std::unique_lock lock{running_mutex};
|
||||
running_cv.wait(lock, [this] { return IsRunning() || exec_step || stop_run; });
|
||||
running_cv.wait(lock, stop_token, [this] { return IsRunning() || exec_step; });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,16 +89,16 @@ public:
|
||||
* Requests for the emulation thread to stop running
|
||||
*/
|
||||
void RequestStop() {
|
||||
stop_run = true;
|
||||
stop_source.request_stop();
|
||||
SetRunning(false);
|
||||
}
|
||||
|
||||
private:
|
||||
bool exec_step = false;
|
||||
bool running = false;
|
||||
std::atomic_bool stop_run{false};
|
||||
std::stop_source stop_source;
|
||||
std::mutex running_mutex;
|
||||
std::condition_variable running_cv;
|
||||
std::condition_variable_any running_cv;
|
||||
Common::Event running_wait{};
|
||||
std::atomic_bool running_guard{false};
|
||||
|
||||
|
Reference in New Issue
Block a user