mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
sys: Get rid of SharedData struct and cleanup code structure (#411)
* sys: Initial refactoring of the SharedData class * sys/pattern: More refactoring, make every provider have its own patterns * sys: Finished up refactoring. No more SharedData! * sys: Fixed compile on Unix * tests: Fixed unit tests * sys: Moved view and lang files * pattern: Added assignment operator support to for loops * tests: Fixed compile issue
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
#include <hex/api/task.hpp>
|
||||
|
||||
#include <hex/helpers/shared_data.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
std::list<Task *> Task::s_runningTasks;
|
||||
std::mutex Task::s_taskMutex;
|
||||
|
||||
Task::Task(const std::string &unlocalizedName, u64 maxValue) : m_name(LangEntry(unlocalizedName)), m_maxValue(maxValue), m_currValue(0) {
|
||||
SharedData::runningTasks.push_back(this);
|
||||
std::scoped_lock lock(Task::s_taskMutex);
|
||||
|
||||
Task::s_runningTasks.push_back(this);
|
||||
}
|
||||
|
||||
Task::~Task() {
|
||||
@@ -13,7 +18,9 @@ namespace hex {
|
||||
}
|
||||
|
||||
void Task::finish() {
|
||||
SharedData::runningTasks.remove(this);
|
||||
std::scoped_lock lock(Task::s_taskMutex);
|
||||
|
||||
Task::s_runningTasks.remove(this);
|
||||
}
|
||||
|
||||
void Task::setMaxValue(u64 maxValue) {
|
||||
@@ -40,4 +47,10 @@ namespace hex {
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
size_t Task::getRunningTaskCount() {
|
||||
std::scoped_lock lock(Task::s_taskMutex);
|
||||
|
||||
return Task::s_runningTasks.size();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user