Sfoglia il codice sorgente

Add destructor to Task

BlackEdder 8 anni fa
parent
commit
18b56280cf
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      src/TaskScheduler.h

+ 7 - 0
src/TaskScheduler.h

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