Use std::atomic rather than a mutex in the progress dialog
This commit is contained in:
parent
bc5417de4a
commit
be930e68ef
1 changed files with 2 additions and 5 deletions
|
@ -27,7 +27,7 @@
|
||||||
#include <libaegisub/dispatch.h>
|
#include <libaegisub/dispatch.h>
|
||||||
#include <libaegisub/exception.h>
|
#include <libaegisub/exception.h>
|
||||||
|
|
||||||
#include <mutex>
|
#include <atomic>
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
#include <wx/gauge.h>
|
#include <wx/gauge.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
|
@ -38,8 +38,7 @@ using agi::dispatch::Main;
|
||||||
|
|
||||||
class DialogProgressSink : public agi::ProgressSink {
|
class DialogProgressSink : public agi::ProgressSink {
|
||||||
DialogProgress *dialog;
|
DialogProgress *dialog;
|
||||||
bool cancelled;
|
std::atomic<bool> cancelled;
|
||||||
std::mutex cancelled_mutex;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogProgressSink(DialogProgress *dialog)
|
DialogProgressSink(DialogProgress *dialog)
|
||||||
|
@ -65,12 +64,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsCancelled() {
|
bool IsCancelled() {
|
||||||
std::lock_guard<std::mutex> lock(cancelled_mutex);
|
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cancel() {
|
void Cancel() {
|
||||||
std::lock_guard<std::mutex> lock(cancelled_mutex);
|
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue