#include "sys/ProgressTask.hpp" #include "logging/logger.hpp" // ---- Construction ---- sys::ProgressTask::ProgressTask(sys::threadpool::JobFunction function, sys::ProgressTask::TaskData taskData) : Task() { taskData->task = this; threadpool::push_job(function, taskData); } // ---- Public functions ---- void sys::ProgressTask::reset(double goal) noexcept { m_current = 0; m_goal = goal; } void sys::ProgressTask::update_current(double current) noexcept { m_current = current; } void sys::ProgressTask::increase_current(double amount) noexcept { m_current += amount; } double sys::ProgressTask::get_goal() const noexcept { return m_goal; } double sys::ProgressTask::get_progress() const noexcept { // Reminder: Never divide by zero. It ends badly every time! return m_goal > 0 ? m_current / m_goal : 0; }