Parcourir la source

Add destructor to Task

BlackEdder il y a 8 ans
Parent
commit
18b56280cf
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      src/TaskScheduler.h

+ 7 - 0
src/TaskScheduler.h

@@ -220,6 +220,7 @@ class Task {
 #ifdef _TASK_STATUS_REQUEST
 		inline Task(void (*aCallback)()=NULL, Scheduler* aScheduler=NULL, bool (*aOnEnable)()=NULL, void (*aOnDisable)()=NULL);
 #endif  // _TASK_STATUS_REQUEST
+        inline ~Task();
 
 		inline void enable();
 		inline bool enableIfNot();
@@ -357,6 +358,12 @@ Task::Task( unsigned long aInterval, long aIterations, void (*aCallback)(), Sche
 	if (aEnable) enable();
 }
 
+Task::~Task() {
+    disable();
+    if (iScheduler)
+        iScheduler->deleteTask(*this);
+}
+
 
 #ifdef _TASK_STATUS_REQUEST