Просмотр исходного кода

v3.1.4 - compiler warnings and access to task chain update

Anatoli Arkhipenko 6 лет назад
Родитель
Сommit
31fe52fab9
3 измененных файлов с 16 добавлено и 22 удалено
  1. 1 2
      keywords.txt
  2. 9 15
      src/TaskScheduler.h
  3. 6 5
      src/TaskSchedulerDeclarations.h

+ 1 - 2
keywords.txt

@@ -20,8 +20,6 @@ Callback	KEYWORD2
 completed	KEYWORD2
 cpuLoadReset	KEYWORD2
 currentLts	KEYWORD2
-currentScheduler	KEYWORD2
-currentTask	KEYWORD2
 delay	KEYWORD2
 deleteTask	KEYWORD2
 disable	KEYWORD2
@@ -39,6 +37,7 @@ getCount	KEYWORD2
 getCpuLoadCycle	KEYWORD2
 getCpuLoadIdle	KEYWORD2
 getCpuLoadTotal	KEYWORD2
+getCurrentTask	KEYWORD2
 getFirstTask	KEYWORD2
 getId	KEYWORD2
 getInternalStatusRequest	KEYWORD2

+ 9 - 15
src/TaskScheduler.h

@@ -871,7 +871,9 @@ long Scheduler::timeUntilNextIteration(Task& aTask) {
     return ( d );
 }
 
-Task& Scheduler::currentTask() { return *iCurrent; }
+
+Task& Scheduler::currentTask() { return *iCurrent; }      // DEPRICATED. Use the next one instead
+Task* Scheduler::getCurrentTask() { return iCurrent; }
 
 #ifdef _TASK_LTS_POINTER
 void* Scheduler::currentLts() { return iCurrent->iLTS; }
@@ -886,6 +888,7 @@ void Scheduler::cpuLoadReset() {
     iCPUIdle = 0;
 }
 
+
 unsigned long Scheduler::getCpuLoadTotal() {
     return (micros() - iCPUStart);
 }
@@ -913,26 +916,20 @@ bool Scheduler::execute() {
     bool     idleRun = true;
     register unsigned long m, i;  // millis, interval;
 
-#if defined (_TASK_SLEEP_ON_IDLE_RUN) || defined (_TASK_TIMECRITICAL)
-    unsigned long tStart, tFinish;
+#ifdef _TASK_SLEEP_ON_IDLE_RUN
+    unsigned long tFinish;
+    unsigned long tStart = micros();
 #endif
 
 #ifdef _TASK_TIMECRITICAL
     register unsigned long tPassStart;
     register unsigned long tTaskStart, tTaskFinish;
-#endif
-
-#if defined (_TASK_SLEEP_ON_IDLE_RUN) && defined (_TASK_TIMECRITICAL)
     unsigned long tIdleStart = 0;
 #endif  // _TASK_TIMECRITICAL
 
-    Task *nextTask;  // support for deleting the task in the onDisable method
+    Task *nextTask;     // support for deleting the task in the onDisable method
     iCurrent = iFirst;
 
-#if defined (_TASK_SLEEP_ON_IDLE_RUN) || defined (_TASK_TIMECRITICAL)
-    tStart = micros();  // Scheduling full pass start time in microseconds. 
-#endif
-
 #ifdef _TASK_PRIORITY
     // If lower priority scheduler does not have a single task in the chain
     // the higher priority scheduler still has to have a chance to run
@@ -1042,12 +1039,9 @@ bool Scheduler::execute() {
 #endif  // ARDUINO_ARCH_ESPxx
     }
 
-#if defined (_TASK_SLEEP_ON_IDLE_RUN) || defined (_TASK_TIMECRITICAL)
-    tFinish = micros(); // Scheduling pass end time in microseconds.
-#endif
-
 
 #ifdef _TASK_SLEEP_ON_IDLE_RUN
+    tFinish = micros(); // Scheduling pass end time in microseconds.
 
     if (idleRun && iAllowSleep) {
         if ( iSleepScheduler == this ) { // only one scheduler should make the MC go to sleep. 

+ 6 - 5
src/TaskSchedulerDeclarations.h

@@ -221,8 +221,8 @@ class Task {
 #endif  // _TASK_LTS_POINTER
 
 #ifdef _TASK_EXPOSE_CHAIN
-    INLINE Task&  getPreviousTask() { return (*iPrev); };   // refernce to the previous task in the chain, NULL if first or not set
-    INLINE Task&  getNextTask()     { return (*iNext); };       // refernce to the next task in the chain, NULL if last or not set
+    INLINE Task*  getPreviousTask() { return iPrev; };  // pointer to the previous task in the chain, NULL if first or not set
+    INLINE Task*  getNextTask()     { return iNext; };  // pointer to the next task in the chain, NULL if last or not set
 #endif // _TASK_EXPOSE_CHAIN
 
 
@@ -284,7 +284,8 @@ class Scheduler {
     INLINE void enableAll(bool aRecursive = true);
     INLINE bool execute();                              // Returns true if none of the tasks' callback methods was invoked (true = idle run)
     INLINE void startNow(bool aRecursive = true);       // reset ALL active tasks to immediate execution NOW.
-    INLINE Task& currentTask() ;
+    INLINE Task& currentTask() ;                        // DEPRICATED
+    INLINE Task* getCurrentTask() ;                     // Returns pointer to the currently active task
     INLINE long timeUntilNextIteration(Task& aTask);    // return number of ms until next iteration of a given Task
 
 #ifdef _TASK_SLEEP_ON_IDLE_RUN
@@ -310,8 +311,8 @@ class Scheduler {
 #endif  // _TASK_PRIORITY
 
 #ifdef _TASK_EXPOSE_CHAIN
-    INLINE Task&  getFirstTask() { return (*iFirst); };    // refernce to the previous task in the chain, NULL if first or not set
-    INLINE Task&  getLastTask()  {   return (*iLast); };       // refernce to the next task in the chain, NULL if last or not set
+    INLINE Task*  getFirstTask() { return iFirst; };       // pointer to the previous task in the chain, NULL if first or not set
+    INLINE Task*  getLastTask()  { return iLast;  };       // pointer to the next task in the chain, NULL if last or not set
 #endif // _TASK_EXPOSE_CHAIN
 
   _TASK_SCOPE: