progress box should use stop source for requesting exit
This commit is contained in:
@@ -57,7 +57,6 @@ private:
|
|||||||
std::string m_transfer{};
|
std::string m_transfer{};
|
||||||
s64 m_size{};
|
s64 m_size{};
|
||||||
s64 m_offset{};
|
s64 m_offset{};
|
||||||
bool m_exit_requested{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is a helper function that does many things.
|
// this is a helper function that does many things.
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ ProgressBox::ProgressBox(const std::string& title, ProgressBoxCallback callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProgressBox::~ProgressBox() {
|
ProgressBox::~ProgressBox() {
|
||||||
mutexLock(&m_mutex);
|
m_stop_source.request_stop();
|
||||||
m_exit_requested = true;
|
|
||||||
mutexUnlock(&m_mutex);
|
|
||||||
|
|
||||||
if (R_FAILED(threadWaitForExit(&m_thread))) {
|
if (R_FAILED(threadWaitForExit(&m_thread))) {
|
||||||
log_write("failed to join thread\n");
|
log_write("failed to join thread\n");
|
||||||
@@ -125,16 +123,11 @@ auto ProgressBox::UpdateTransfer(s64 offset, s64 size) -> ProgressBox& {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProgressBox::RequestExit() {
|
void ProgressBox::RequestExit() {
|
||||||
mutexLock(&m_mutex);
|
m_stop_source.request_stop();
|
||||||
m_exit_requested = true;
|
|
||||||
mutexUnlock(&m_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProgressBox::ShouldExit() -> bool {
|
auto ProgressBox::ShouldExit() -> bool {
|
||||||
mutexLock(&m_mutex);
|
return m_stop_source.stop_requested();
|
||||||
const auto exit_requested = m_exit_requested;
|
|
||||||
mutexUnlock(&m_mutex);
|
|
||||||
return exit_requested;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ProgressBox::CopyFile(const fs::FsPath& src_path, const fs::FsPath& dst_path) -> Result {
|
auto ProgressBox::CopyFile(const fs::FsPath& src_path, const fs::FsPath& dst_path) -> Result {
|
||||||
|
|||||||
Reference in New Issue
Block a user