diff --git a/sphaira/include/ui/progress_box.hpp b/sphaira/include/ui/progress_box.hpp index b9c6551..ab5a590 100644 --- a/sphaira/include/ui/progress_box.hpp +++ b/sphaira/include/ui/progress_box.hpp @@ -57,7 +57,6 @@ private: std::string m_transfer{}; s64 m_size{}; s64 m_offset{}; - bool m_exit_requested{}; }; // this is a helper function that does many things. diff --git a/sphaira/source/ui/progress_box.cpp b/sphaira/source/ui/progress_box.cpp index 610023a..a3445d2 100644 --- a/sphaira/source/ui/progress_box.cpp +++ b/sphaira/source/ui/progress_box.cpp @@ -52,9 +52,7 @@ ProgressBox::ProgressBox(const std::string& title, ProgressBoxCallback callback, } ProgressBox::~ProgressBox() { - mutexLock(&m_mutex); - m_exit_requested = true; - mutexUnlock(&m_mutex); + m_stop_source.request_stop(); if (R_FAILED(threadWaitForExit(&m_thread))) { log_write("failed to join thread\n"); @@ -125,16 +123,11 @@ auto ProgressBox::UpdateTransfer(s64 offset, s64 size) -> ProgressBox& { } void ProgressBox::RequestExit() { - mutexLock(&m_mutex); - m_exit_requested = true; - mutexUnlock(&m_mutex); + m_stop_source.request_stop(); } auto ProgressBox::ShouldExit() -> bool { - mutexLock(&m_mutex); - const auto exit_requested = m_exit_requested; - mutexUnlock(&m_mutex); - return exit_requested; + return m_stop_source.stop_requested(); } auto ProgressBox::CopyFile(const fs::FsPath& src_path, const fs::FsPath& dst_path) -> Result {