2021-12-16 23:48:52 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
#include <list>
|
|
|
|
#include <mutex>
|
2021-12-16 23:48:52 +01:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
class Task {
|
|
|
|
public:
|
2022-01-24 20:53:17 +01:00
|
|
|
Task(const std::string &unlocalizedName, u64 maxValue);
|
2021-12-16 23:48:52 +01:00
|
|
|
~Task();
|
|
|
|
|
2022-01-09 21:27:59 +01:00
|
|
|
void setMaxValue(u64 maxValue);
|
2021-12-16 23:48:52 +01:00
|
|
|
void update(u64 currValue);
|
|
|
|
void finish();
|
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
[[nodiscard]] double getProgress() const;
|
2021-12-16 23:48:52 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
[[nodiscard]] const std::string &getName() const;
|
2021-12-16 23:48:52 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
[[nodiscard]] bool isPending() const;
|
2022-01-09 21:27:59 +01:00
|
|
|
|
2022-02-01 18:09:40 +01:00
|
|
|
static size_t getRunningTaskCount();
|
2022-02-01 22:09:44 +01:00
|
|
|
static std::list<Task *> &getRunningTasks() { return Task::s_runningTasks; }
|
|
|
|
static std::mutex &getTaskMutex() { return Task::s_taskMutex; }
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2021-12-16 23:48:52 +01:00
|
|
|
private:
|
|
|
|
std::string m_name;
|
|
|
|
u64 m_maxValue, m_currValue;
|
2022-02-01 18:09:40 +01:00
|
|
|
|
|
|
|
static std::list<Task *> s_runningTasks;
|
|
|
|
static std::mutex s_taskMutex;
|
2021-12-16 23:48:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|