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