sneedmc/launcher/minecraft/mod/tasks/LocalModParseTask.h
flow 42c81395b3
fix: race condition on ResourceFolderModel tests
This (hopefully) fixes the race contiditions that sometimes got
triggered in tests.

Signed-off-by: flow <flowlnlnln@gmail.com>
2022-09-03 13:37:22 -03:00

44 lines
875 B
C++

#pragma once
#include <QDebug>
#include <QObject>
#include "minecraft/mod/Mod.h"
#include "minecraft/mod/ModDetails.h"
#include "tasks/Task.h"
class LocalModParseTask : public Task
{
Q_OBJECT
public:
struct Result {
ModDetails details;
};
using ResultPtr = std::shared_ptr<Result>;
ResultPtr result() const {
return m_result;
}
[[nodiscard]] bool canAbort() const override { return true; }
bool abort() override;
LocalModParseTask(int token, ResourceType type, const QFileInfo & modFile);
void executeTask() override;
[[nodiscard]] int token() const { return m_token; }
private:
void processAsZip();
void processAsFolder();
void processAsLitemod();
private:
int m_token;
ResourceType m_type;
QFileInfo m_modFile;
ResultPtr m_result;
std::atomic<bool> m_aborted = false;
};