mirror of
https://github.com/modelec/MarcelMoteur.git
synced 2026-01-18 16:27:22 +01:00
refactor: simplify Task class
This commit is contained in:
@@ -1,48 +1,29 @@
|
||||
#include "Task.h"
|
||||
|
||||
// Constructeur
|
||||
Task::Task() : is_paused(false), is_running(false) {}
|
||||
Task::Task() : is_running(false) {}
|
||||
|
||||
Task::~Task()
|
||||
{
|
||||
// Si la tâche est en cours d'exécution, on l'arrête
|
||||
stop();
|
||||
}
|
||||
|
||||
// Démarre la tâche
|
||||
void Task::start()
|
||||
{
|
||||
|
||||
is_running = true;
|
||||
is_paused = false;
|
||||
}
|
||||
|
||||
// Met en pause la tâche
|
||||
void Task::pause()
|
||||
{
|
||||
if (is_running && !is_paused)
|
||||
{
|
||||
is_paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Reprend la tâche
|
||||
void Task::resume()
|
||||
{
|
||||
if (is_paused)
|
||||
{
|
||||
is_paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Arrête la tâche
|
||||
void Task::stop()
|
||||
{
|
||||
if (is_running)
|
||||
{
|
||||
|
||||
is_running = false;
|
||||
is_paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
bool Task::isPaused()
|
||||
{
|
||||
return is_paused;
|
||||
}
|
||||
bool Task::isRunning()
|
||||
{
|
||||
return is_running;
|
||||
|
||||
@@ -4,21 +4,16 @@
|
||||
class Task
|
||||
{
|
||||
private:
|
||||
bool is_paused;
|
||||
bool is_running;
|
||||
|
||||
public:
|
||||
Task(); // Constructeur
|
||||
// Mise en pause de la tâche
|
||||
void pause();
|
||||
// Reprise de la tâche
|
||||
void resume();
|
||||
~Task(); // Déstructeur
|
||||
// Démarrage de la tâche
|
||||
void start();
|
||||
// Arrêt de la tâche
|
||||
void stop();
|
||||
// Getters
|
||||
bool isPaused();
|
||||
bool isRunning();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user