render: fix issue responding to cancelled tasks

This commit is contained in:
itsmattkc
2022-07-10 12:54:55 -07:00
parent 963ffe8de3
commit a8d46c4c5f
17 changed files with 98 additions and 164 deletions
+48
View File
@@ -0,0 +1,48 @@
#ifndef CANCELATOM_H
#define CANCELATOM_H
#include <QMutex>
namespace olive {
class CancelAtom
{
public:
CancelAtom() :
cancelled_(false),
heard_(false)
{}
bool IsCancelled()
{
QMutexLocker locker(&mutex_);
if (cancelled_) {
heard_ = true;
}
return cancelled_;
}
void Cancel()
{
QMutexLocker locker(&mutex_);
cancelled_ = true;
}
bool HeardCancel()
{
QMutexLocker locker(&mutex_);
return heard_;
}
private:
QMutex mutex_;
bool cancelled_;
bool heard_;
};
}
#endif // CANCELATOM_H