Ver código fonte

v4.0.0_rc3 - bug fixes. allow STD::FUNCTIONS and DON_NOT _YIELD for non-ESP platforms

Anatoli Arkhipenko 4 meses atrás
pai
commit
b676308b2b
2 arquivos alterados com 183 adições e 175 exclusões
  1. 54 46
      src/TaskScheduler.h
  2. 129 129
      src/TaskSchedulerDeclarations.h

+ 54 - 46
src/TaskScheduler.h

@@ -277,10 +277,14 @@ v4.0.0:
         - Major rework of the _TASK_THREAD_SAFE approach. Developers should only be calling Scheduler and Task methods
           directly from the thread where TaskScheduler execute() method runs. 
           Calls from the other threads should be done via Scheduler::requestAction(...) methods. 
-          Target platform should implement a action queue and two methods:
+          Target platform should implement an action queue and two methods:
              bool _task_enqueue_request(_task_request_t* req);  // puts _task_request_t object on the action queue
              bool _task_dequeue_request(_task_request_t* req);  // retrieves _task_request_t object from the action queue
              Please see examples folder for implementation folder.
+    
+    2025-09-13:
+        - feature: allow _TASK_STD_FUNCTION for all platforms (you should know what you are doing)
+        - feature: allow _TASK_DO_NOT_YIELD for all platforms (you should know what you are doing)
 */
 
 #include "TaskSchedulerDeclarations.h"
@@ -317,10 +321,10 @@ v4.0.0:
  #ifdef _TASK_MICRO_RES
 
  #undef _TASK_SLEEP_ON_IDLE_RUN     // SLEEP_ON_IDLE has only millisecond resolution
- #define _TASK_TIME_FUNCTION() _task_micros()
+ #define __TASK_TIME_FUNCTION() _task_micros()
 
  #else
- #define _TASK_TIME_FUNCTION() _task_millis()
+ #define __TASK_TIME_FUNCTION() _task_millis()
 
  #endif  // _TASK_MICRO_RES
 
@@ -334,15 +338,16 @@ v4.0.0:
 #endif  // _TASK_SLEEP_ON_IDLE_RUN
 
 
-#if !defined (ARDUINO_ARCH_ESP8266) && !defined (ARDUINO_ARCH_ESP32) && !defined (ARDUINO_ARCH_STM32)
-#ifdef _TASK_STD_FUNCTION
-    #error Support for std::function only for ESP8266 or ESP32 architecture
-#undef _TASK_STD_FUNCTION
-#endif // _TASK_STD_FUNCTION
-#endif // ARDUINO_ARCH_ESP8266
+// _TASK_STD_FUNCTION is allowed for all platforms - you should know what you are doing
+// #if !defined (ARDUINO_ARCH_ESP8266) && !defined (ARDUINO_ARCH_ESP32) && !defined (ARDUINO_ARCH_STM32)
+// #ifdef _TASK_STD_FUNCTION
+//     #error Support for std::function only for ESP8266 or ESP32 architecture
+// #undef _TASK_STD_FUNCTION
+// #endif // _TASK_STD_FUNCTION
+// #endif // ARDUINO_ARCH_ESP8266
 
 #ifdef _TASK_WDT_IDS
-    static unsigned int  _task_id_counter = 0; // global task ID counter for assiging task IDs automatically.
+    static unsigned int  __task_id_counter = 0; // global task ID counter for assiging task IDs automatically.
 #endif  // _TASK_WDT_IDS
 
 #ifdef _TASK_PRIORITY
@@ -419,7 +424,7 @@ Task::Task( unsigned long aInterval, long aIterations, TaskCallback aCallback, S
     if (aScheduler) aScheduler->addTask(*this);
 
 #ifdef _TASK_WDT_IDS
-    iTaskID = ++ _task_id_counter;
+    iTaskID = ++ __task_id_counter;
 #endif  // _TASK_WDT_IDS
 
     if (aEnable) enable();
@@ -455,7 +460,7 @@ Task::Task( TaskCallback aCallback, Scheduler* aScheduler, TaskOnEnable aOnEnabl
     if (aScheduler) aScheduler->addTask(*this);
 
 #ifdef _TASK_WDT_IDS
-    iTaskID = ++ _task_id_counter;
+    iTaskID = ++ __task_id_counter;
 #endif  // _TASK_WDT_IDS
 }
 
@@ -470,7 +475,7 @@ void StatusRequest::setWaiting(unsigned int aCount) {
   iCount = aCount; 
   iStatus = 0; 
 #ifdef _TASK_TIMEOUT
-  iStarttime = _TASK_TIME_FUNCTION();
+  iStarttime = __TASK_TIME_FUNCTION();
 #endif  //  #ifdef _TASK_TIMEOUT
 }
 
@@ -486,7 +491,7 @@ StatusRequest* Task::getInternalStatusRequest() { return &iMyStatusRequest; }
  *  Negative status will complete Status Request fully (since an error occured).
  *  @return: true, if StatusRequest is complete, false otherwise (still waiting for other events)
  */
-bool _TASK_IRAM StatusRequest::signal(int aStatus) {
+bool __TASK_IRAM StatusRequest::signal(int aStatus) {
     if ( iCount) {  // do not update the status request if it was already completed
         if (iCount > 0)  --iCount;
         if ( (iStatus = aStatus) < 0 ) iCount = 0;   // if an error is reported, the status is requested to be completed immediately
@@ -494,7 +499,7 @@ bool _TASK_IRAM StatusRequest::signal(int aStatus) {
     return (iCount == 0);
 }
 
-void _TASK_IRAM StatusRequest::signalComplete(int aStatus) {
+void __TASK_IRAM StatusRequest::signalComplete(int aStatus) {
     if (iCount) { // do not update the status request if it was already completed
         iCount = 0;
         iStatus = aStatus;
@@ -529,12 +534,12 @@ bool Task::waitForDelayed(StatusRequest* aStatusRequest, unsigned long aInterval
 
 #ifdef _TASK_TIMEOUT
 void StatusRequest::resetTimeout() {
-    iStarttime = _TASK_TIME_FUNCTION();
+    iStarttime = __TASK_TIME_FUNCTION();
 }
 
 long StatusRequest::untilTimeout() {
     if ( iTimeout ) {
-        return ( (long) (iStarttime + iTimeout) - (long) _TASK_TIME_FUNCTION() );
+        return ( (long) (iStarttime + iTimeout) - (long) __TASK_TIME_FUNCTION() );
     }
     return -1;
 }
@@ -633,7 +638,8 @@ void Task::set(unsigned long aInterval, long aIterations, TaskCallback aCallback
     iOnDisable = aOnDisable;
 #endif // _TASK_OO_CALLBACKS
     setInterval(aInterval);
-    iSetIterations = iIterations = aIterations;
+    iSetIterations = aIterations;
+    iIterations = aIterations;
 }
 
 /** Sets number of iterations for the task
@@ -641,7 +647,8 @@ void Task::set(unsigned long aInterval, long aIterations, TaskCallback aCallback
  * @param aIterations - number of iterations, use -1 for no limit
  */
 void Task::setIterations(long aIterations) {
-    iSetIterations = iIterations = aIterations;
+    iSetIterations = aIterations;
+    iIterations = aIterations;
 }
 
 #ifndef _TASK_OO_CALLBACKS
@@ -674,7 +681,7 @@ void Task::yieldOnce (TaskCallback aCallback) {
  *  schedules it for execution as soon as possible,
  *  and resets the RunCounter back to zero
  */
-bool _TASK_IRAM Task::enable() {
+bool __TASK_IRAM Task::enable() {
     if (iScheduler) { // activation without active scheduler does not make sense
         iRunCounter = 0;
         iStatus.canceled = false;
@@ -707,7 +714,7 @@ bool _TASK_IRAM Task::enable() {
 #endif // _TASK_OO_CALLBACKS
 
         iDelay = iInterval;
-        iPreviousMillis = _TASK_TIME_FUNCTION() - iDelay;
+        iPreviousMillis = __TASK_TIME_FUNCTION() - iDelay;
 
 #ifdef _TASK_TIMEOUT
         resetTimeout();
@@ -726,7 +733,7 @@ bool _TASK_IRAM Task::enable() {
 /** Enables the task only if it was not enabled already
  * Returns previous state (true if was already enabled, false if was not)
  */
-bool _TASK_IRAM Task::enableIfNot() {
+bool __TASK_IRAM Task::enableIfNot() {
     bool previousEnabled = iStatus.enabled;
     if ( !previousEnabled ) enable();
     return (previousEnabled);
@@ -735,7 +742,7 @@ bool _TASK_IRAM Task::enableIfNot() {
 /** Enables the task
  * and schedules it for execution after a delay = aInterval
  */
-bool _TASK_IRAM Task::enableDelayed(unsigned long aDelay) {
+bool __TASK_IRAM Task::enableDelayed(unsigned long aDelay) {
     enable();
     delay(aDelay);
     return iStatus.enabled;
@@ -748,7 +755,7 @@ void Task::setTimeout(unsigned long aTimeout, bool aReset) {
 }
 
 void Task::resetTimeout() {
-    iStarttime = _TASK_TIME_FUNCTION();
+    iStarttime = __TASK_TIME_FUNCTION();
     iStatus.timeout = false;
 }
 
@@ -758,7 +765,7 @@ unsigned long Task::getTimeout() {
 
 long Task::untilTimeout() {
     if ( iTimeout ) {
-        return ( (long) (iStarttime + iTimeout) - (long) _TASK_TIME_FUNCTION() );
+        return ( (long) (iStarttime + iTimeout) - (long) __TASK_TIME_FUNCTION() );
     }
     return -1;
 }
@@ -775,9 +782,9 @@ bool Task::timedOut() {
  * leaves task enabled or disabled
  * if aDelay is zero, delays for the original scheduling interval from now
  */
-void _TASK_IRAM Task::delay(unsigned long aDelay) {
+void __TASK_IRAM Task::delay(unsigned long aDelay) {
     iDelay = aDelay ? aDelay : iInterval;
-    iPreviousMillis = _TASK_TIME_FUNCTION(); 
+    iPreviousMillis = __TASK_TIME_FUNCTION(); 
 }
 
 /** Adjusts Task execution with aInterval (if task is enabled).
@@ -798,9 +805,9 @@ void Task::adjust(long aInterval) {
  * leaves task enabled or disabled
  * Task's original schedule is shifted, and all subsequent iterations will continue from this point in time
  */
-void _TASK_IRAM Task::forceNextIteration() {
+void __TASK_IRAM Task::forceNextIteration() {
     iDelay = iInterval;
-    iPreviousMillis = _TASK_TIME_FUNCTION() - iDelay;
+    iPreviousMillis = __TASK_TIME_FUNCTION() - iDelay;
 }
 
 /** Sets the execution interval.
@@ -855,7 +862,7 @@ void Task::setIntervalNodelay (unsigned long aInterval, unsigned int aOption) {
  * Returns status of the task before disable was called (i.e., if the task was already disabled)
  */
 
-bool _TASK_IRAM Task::disable() {
+bool __TASK_IRAM Task::disable() {
     bool previousEnabled = iStatus.enabled;
     iStatus.enabled = false;
     iStatus.inonenable = false;
@@ -889,7 +896,7 @@ bool _TASK_IRAM Task::disable() {
 /** Aborts task execution
  * Task will no longer be executed by the scheduler AND ondisable method will not be called
  */
-void _TASK_IRAM Task::abort() {
+void __TASK_IRAM Task::abort() {
     iStatus.enabled = false;
     iStatus.inonenable = false;
     iStatus.canceled = true;
@@ -906,7 +913,7 @@ void _TASK_IRAM Task::abort() {
 /** Cancels task execution
  * Task will no longer be executed by the scheduler. Ondisable method will be called after 'canceled' flag is set
  */
-void _TASK_IRAM Task::cancel() {
+void __TASK_IRAM Task::cancel() {
     iStatus.canceled = true;
 #ifdef _TASK_STATUS_REQUEST
     iMyStatusRequest.signalComplete(TASK_SR_ABORT);
@@ -922,7 +929,7 @@ bool Task::canceled() {
  * Task will run number of iterations again
  */
 
-bool _TASK_IRAM Task::restart() {
+bool __TASK_IRAM Task::restart() {
     iIterations = iSetIterations;
     return enable();
 }
@@ -930,7 +937,7 @@ bool _TASK_IRAM Task::restart() {
 /** Restarts task delayed
  * Task will run number of iterations again
  */
-bool _TASK_IRAM Task::restartDelayed(unsigned long aDelay) {
+bool __TASK_IRAM Task::restartDelayed(unsigned long aDelay) {
     iIterations = iSetIterations;
     return enableDelayed(aDelay);
 }
@@ -1166,7 +1173,7 @@ void Scheduler::startNow( bool aRecursive ) {
 #else
 void Scheduler::startNow() {
 #endif
-    unsigned long t = _TASK_TIME_FUNCTION();
+    unsigned long t = __TASK_TIME_FUNCTION();
 
     iEnabled = false;
     
@@ -1198,7 +1205,7 @@ long Scheduler::timeUntilNextIteration(Task& aTask) {
     if ( !aTask.isEnabled() )
         return (-1);    // cannot be determined
 
-    long d = (long) aTask.iDelay - ( (long) (_TASK_TIME_FUNCTION() - aTask.iPreviousMillis) );
+    long d = (long) aTask.iDelay - ( (long) (__TASK_TIME_FUNCTION() - aTask.iPreviousMillis) );
 
     if ( d < 0 )
         return (0); // Task will run as soon as possible
@@ -1239,13 +1246,13 @@ void  Scheduler::setSleepMethod( SleepCallback aCallback ) {
 #endif  // _TASK_SLEEP_ON_IDLE_RUN
 
 #ifdef  _TASK_THREAD_SAFE
-void Scheduler::requestAction(_task_request_t* aRequest) {
-    if ( aRequest == NULL ) return; 
-    _task_enqueue_request(aRequest);
+bool Scheduler::requestAction(_task_request_t* aRequest) {
+    if ( aRequest == NULL ) return false; 
+    return _task_enqueue_request(aRequest);
 }
 
-void Scheduler::requestAction(void* aObject, _task_request_type_t aType, unsigned long aParam1, unsigned long aParam2, unsigned long aParam3, unsigned long aParam4, unsigned long aParam5) {
-    if ( aObject == NULL ) return; 
+bool Scheduler::requestAction(void* aObject, _task_request_type_t aType, unsigned long aParam1, unsigned long aParam2, unsigned long aParam3, unsigned long aParam4, unsigned long aParam5) {
+    if ( aObject == NULL ) return false; 
     _task_request_t r = {
         .req_type = aType,
         .object_ptr = aObject,
@@ -1255,7 +1262,7 @@ void Scheduler::requestAction(void* aObject, _task_request_type_t aType, unsigne
         .param4 = aParam4,
         .param5 = aParam5
     };
-    _task_enqueue_request(&r);
+    return _task_enqueue_request(&r);
 }
 
 void Scheduler::processRequests() {
@@ -1586,7 +1593,7 @@ bool Scheduler::execute() {
 #endif  //  #ifdef _TASK_SELF_DESTRUCT
                     break;
                 }
-                m = _TASK_TIME_FUNCTION();
+                m = __TASK_TIME_FUNCTION();
                 i = iCurrent->iInterval;
 
 #ifdef _TASK_TIMEOUT
@@ -1726,11 +1733,12 @@ bool Scheduler::execute() {
         iCPUCycle += ( (_task_micros() - tPassStart) - (tTaskFinish - tTaskStart) );
 #endif  // _TASK_TIMECRITICAL
         
-#if defined (ARDUINO_ARCH_ESP8266) || defined (ARDUINO_ARCH_ESP32) 
+// _TASK_DO_NOT_YIELD is allowed for everyone - you should know what you are doing
+// #if defined (ARDUINO_ARCH_ESP8266) || defined (ARDUINO_ARCH_ESP32) 
 #if !defined(_TASK_DO_NOT_YIELD)
         _task_yield();
 #endif  //  _TASK_DO_NOT_YIELD
-#endif  //  ARDUINO_ARCH_ESPxx
+// #endif  //  ARDUINO_ARCH_ESPxx
     }
 
 #ifdef _TASK_SLEEP_ON_IDLE_RUN
@@ -1744,7 +1752,7 @@ bool Scheduler::execute() {
         if ( !idleRun ) break;
         if ( (nrd & _TASK_NEXTRUN_IMMEDIATE) ) break;
         if ( nrd == _TASK_NEXTRUN_UNDEFINED ) break;
-        m = _TASK_TIME_FUNCTION();
+        m = __TASK_TIME_FUNCTION();
         if ( nr <= m) break;
         iNextRun = ( nr - m );
     } while (0);

+ 129 - 129
src/TaskSchedulerDeclarations.h

@@ -74,21 +74,21 @@ class Scheduler;
 #endif // _TASK_PRIORITY
 
 #ifdef _TASK_INLINE
-#define _TASK_INLINE  inline
+#define __TASK_INLINE  inline
 #else
-#define _TASK_INLINE
+#define __TASK_INLINE
 #endif
 
 #ifdef _TASK_ISR_SUPPORT
 #if defined (ARDUINO_ARCH_ESP8266)
-#define _TASK_IRAM ICACHE_RAM_ATTR
+#define __TASK_IRAM ICACHE_RAM_ATTR
 #endif 
 #if  defined (ARDUINO_ARCH_ESP32)
-#define _TASK_IRAM IRAM_ATTR
+#define __TASK_IRAM IRAM_ATTR
 #endif
 #endif
-#ifndef _TASK_IRAM
-#define _TASK_IRAM
+#ifndef __TASK_IRAM
+#define __TASK_IRAM
 #endif
 
 #ifndef _TASK_MICRO_RES
@@ -179,10 +179,10 @@ typedef enum {
 // void setWaiting(unsigned int aCount = 1);
 #define TASK_SR_REQUEST_SETWAITING_1        TASK_SR_REQUEST_SETWAITING
 #define TASK_SR_REQUEST_SETWAITING_1_DEFAULT   1
-// _TASK_IRAM signal(int aStatus = 0);
+// __TASK_IRAM signal(int aStatus = 0);
 #define TASK_SR_REQUEST_SIGNAL_1            TASK_SR_REQUEST_SIGNAL
 #define TASK_SR_REQUEST_SIGNAL_1_DEFAULT    0
-// _TASK_IRAM signalComplete(int aStatus = 0);
+// __TASK_IRAM signalComplete(int aStatus = 0);
 #define TASK_SR_REQUEST_SIGNALCOMPLETE_1    TASK_SR_REQUEST_SIGNALCOMPLETE
 #define TASK_SR_REQUEST_SIGNALCOMPLETE_1_DEFAULT    0
 
@@ -231,30 +231,30 @@ typedef enum {
 #endif  // _TASK_STATUS_REQUEST
 
 #ifdef _TASK_WDT_IDS
-// _TASK_INLINE void setId(unsigned int aID) ;
+// __TASK_INLINE void setId(unsigned int aID) ;
 #define TASK_REQUEST_SETID_1                TASK_REQUEST_SETID
-// _TASK_INLINE void setControlPoint(unsigned int aPoint) ;
+// __TASK_INLINE void setControlPoint(unsigned int aPoint) ;
 #define TASK_REQUEST_SETCONTROLPOINT_1      TASK_REQUEST_SETCONTROLPOINT
 #endif  // _TASK_WDT_IDS
 
-// bool _TASK_IRAM enable();
+// bool __TASK_IRAM enable();
 #define TASK_REQUEST_ENABLE_0               TASK_REQUEST_ENABLE
-// bool _TASK_IRAM enableIfNot();
+// bool __TASK_IRAM enableIfNot();
 #define TASK_REQUEST_ENABLEIFNOT_0          TASK_REQUEST_ENABLEIFNOT
-// bool _TASK_IRAM enableDelayed(unsigned long aDelay=0);
+// bool __TASK_IRAM enableDelayed(unsigned long aDelay=0);
 #define TASK_REQUEST_ENABLEDELAYED_1        TASK_REQUEST_ENABLEDELAYED
 #define TASK_REQUEST_ENABLEDELAYED_1_DEFAULT    0
-// bool _TASK_IRAM restart();
+// bool __TASK_IRAM restart();
 #define TASK_REQUEST_RESTART_0              TASK_REQUEST_RESTART
-// bool _TASK_IRAM restartDelayed(unsigned long aDelay=0);
+// bool __TASK_IRAM restartDelayed(unsigned long aDelay=0);
 #define TASK_REQUEST_RESTARTDELAYED_1       TASK_REQUEST_RESTARTDELAYED
 #define TASK_REQUEST_RESTARTDELAYED_1_DEFAULT   0
-// void _TASK_IRAM delay(unsigned long aDelay=0);
+// void __TASK_IRAM delay(unsigned long aDelay=0);
 #define TASK_REQUEST_DELAY_1                TASK_REQUEST_DELAY
 #define TASK_REQUEST_DELAY_1_DEFAULT    0
 // void adjust(long aInterval);
 #define TASK_REQUEST_ADJUST_1               TASK_REQUEST_ADJUST
-// void _TASK_IRAM forceNextIteration();
+// void __TASK_IRAM forceNextIteration();
 #define TASK_REQUEST_FORCENEXTITERATION_0   TASK_REQUEST_FORCENEXTITERATION
 // bool disable();
 #define TASK_REQUEST_DISABLE_0              TASK_REQUEST_DISABLE
@@ -307,20 +307,20 @@ typedef struct {
 class StatusRequest {
   friend class Scheduler;
   public:
-    _TASK_INLINE StatusRequest();
-    _TASK_INLINE void setWaiting(unsigned int aCount = 1);
-    _TASK_INLINE bool _TASK_IRAM signal(int aStatus = 0);
-    _TASK_INLINE void _TASK_IRAM signalComplete(int aStatus = 0);
-    _TASK_INLINE bool pending();
-    _TASK_INLINE bool completed();
-    _TASK_INLINE int  getStatus();
-    _TASK_INLINE int  getCount();
+    __TASK_INLINE StatusRequest();
+    __TASK_INLINE void setWaiting(unsigned int aCount = 1);
+    __TASK_INLINE bool  signal(int aStatus = 0);
+    __TASK_INLINE void  signalComplete(int aStatus = 0);
+    __TASK_INLINE bool pending();
+    __TASK_INLINE bool completed();
+    __TASK_INLINE int  getStatus();
+    __TASK_INLINE int  getCount();
     
 #ifdef _TASK_TIMEOUT
-    _TASK_INLINE void setTimeout(unsigned long aTimeout) { iTimeout = aTimeout; };
-    _TASK_INLINE unsigned long getTimeout() { return iTimeout; };
-    _TASK_INLINE void resetTimeout();
-    _TASK_INLINE long untilTimeout();
+    __TASK_INLINE void setTimeout(unsigned long aTimeout) { iTimeout = aTimeout; };
+    __TASK_INLINE unsigned long getTimeout() { return iTimeout; };
+    __TASK_INLINE void resetTimeout();
+    __TASK_INLINE long untilTimeout();
 #endif
 
   _TASK_SCOPE:
@@ -376,14 +376,14 @@ class Task {
   public:
 
 #ifdef _TASK_OO_CALLBACKS
-    _TASK_INLINE Task(unsigned long aInterval=0, long aIterations=0, Scheduler* aScheduler=NULL, bool aEnable=false
+    __TASK_INLINE Task(unsigned long aInterval=0, long aIterations=0, Scheduler* aScheduler=NULL, bool aEnable=false
 #ifdef _TASK_SELF_DESTRUCT
     , bool aSelfDestruct=false);
 #else
     );
 #endif  // #ifdef _TASK_SELF_DESTRUCT
 #else
-    _TASK_INLINE Task(unsigned long aInterval=0, long aIterations=0, TaskCallback aCallback=NULL, Scheduler* aScheduler=NULL, bool aEnable=false, TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL
+    __TASK_INLINE Task(unsigned long aInterval=0, long aIterations=0, TaskCallback aCallback=NULL, Scheduler* aScheduler=NULL, bool aEnable=false, TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL
 #ifdef _TASK_SELF_DESTRUCT
   , bool aSelfDestruct=false);
 #else
@@ -394,107 +394,107 @@ class Task {
 
 #ifdef _TASK_STATUS_REQUEST
 #ifdef _TASK_OO_CALLBACKS
-//    _TASK_INLINE Task(Scheduler* aScheduler=NULL);
-    _TASK_INLINE Task(Scheduler* aScheduler);
+//    __TASK_INLINE Task(Scheduler* aScheduler=NULL);
+    __TASK_INLINE Task(Scheduler* aScheduler);
 #else
-//    _TASK_INLINE Task(TaskCallback aCallback=NULL, Scheduler* aScheduler=NULL, TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL);
-    _TASK_INLINE Task(TaskCallback aCallback, Scheduler* aScheduler, TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL);
+//    __TASK_INLINE Task(TaskCallback aCallback=NULL, Scheduler* aScheduler=NULL, TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL);
+    __TASK_INLINE Task(TaskCallback aCallback, Scheduler* aScheduler, TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL);
 #endif // _TASK_OO_CALLBACKS
 #endif  // _TASK_STATUS_REQUEST
 
-    virtual _TASK_INLINE ~Task();
+    virtual __TASK_INLINE ~Task();
 
 #ifdef _TASK_TIMEOUT
-    _TASK_INLINE void setTimeout(unsigned long aTimeout, bool aReset=false);
-    _TASK_INLINE void resetTimeout();
-    _TASK_INLINE unsigned long getTimeout();
-    _TASK_INLINE long untilTimeout();
-    _TASK_INLINE bool timedOut();
+    __TASK_INLINE void setTimeout(unsigned long aTimeout, bool aReset=false);
+    __TASK_INLINE void resetTimeout();
+    __TASK_INLINE unsigned long getTimeout();
+    __TASK_INLINE long untilTimeout();
+    __TASK_INLINE bool timedOut();
 #endif
 
-    _TASK_INLINE bool _TASK_IRAM enable();
-    _TASK_INLINE bool _TASK_IRAM enableIfNot();
-    _TASK_INLINE bool _TASK_IRAM enableDelayed(unsigned long aDelay=0);
-    _TASK_INLINE bool _TASK_IRAM restart();
-    _TASK_INLINE bool _TASK_IRAM restartDelayed(unsigned long aDelay=0);
-
-    _TASK_INLINE void _TASK_IRAM delay(unsigned long aDelay=0);
-    _TASK_INLINE void adjust(long aInterval);
-    _TASK_INLINE void _TASK_IRAM forceNextIteration();
-    _TASK_INLINE bool _TASK_IRAM disable();
-    _TASK_INLINE void _TASK_IRAM abort();
-    _TASK_INLINE void _TASK_IRAM cancel();
-    _TASK_INLINE bool isEnabled();
-    _TASK_INLINE bool canceled();
+    __TASK_INLINE bool  enable();
+    __TASK_INLINE bool  enableIfNot();
+    __TASK_INLINE bool  enableDelayed(unsigned long aDelay=0);
+    __TASK_INLINE bool  restart();
+    __TASK_INLINE bool  restartDelayed(unsigned long aDelay=0);
+
+    __TASK_INLINE void  delay(unsigned long aDelay=0);
+    __TASK_INLINE void adjust(long aInterval);
+    __TASK_INLINE void  forceNextIteration();
+    __TASK_INLINE bool  disable();
+    __TASK_INLINE void  abort();
+    __TASK_INLINE void  cancel();
+    __TASK_INLINE bool isEnabled();
+    __TASK_INLINE bool canceled();
 
 #ifdef _TASK_SCHEDULING_OPTIONS
-    _TASK_INLINE unsigned int getSchedulingOption() { return iOption; }
-    _TASK_INLINE void setSchedulingOption(unsigned int aOption) {  iOption = aOption; }
+    __TASK_INLINE unsigned int getSchedulingOption() { return iOption; }
+    __TASK_INLINE void setSchedulingOption(unsigned int aOption) {  iOption = aOption; }
 #endif  //_TASK_SCHEDULING_OPTIONS
 
 #ifdef _TASK_OO_CALLBACKS
-    _TASK_INLINE void set(unsigned long aInterval, long aIterations);
+    __TASK_INLINE void set(unsigned long aInterval, long aIterations);
 #else
-    _TASK_INLINE void set(unsigned long aInterval, long aIterations, TaskCallback aCallback,TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL);
+    __TASK_INLINE void set(unsigned long aInterval, long aIterations, TaskCallback aCallback,TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL);
 #endif // _TASK_OO_CALLBACKS
-    _TASK_INLINE void setInterval(unsigned long aInterval);
-    _TASK_INLINE void setIntervalNodelay(unsigned long aInterval, unsigned int aOption = TASK_INTERVAL_KEEP);
-    _TASK_INLINE unsigned long getInterval();
-    _TASK_INLINE void setIterations(long aIterations);
-    _TASK_INLINE long getIterations();
-    _TASK_INLINE unsigned long getRunCounter();
+    __TASK_INLINE void setInterval(unsigned long aInterval);
+    __TASK_INLINE void setIntervalNodelay(unsigned long aInterval, unsigned int aOption = TASK_INTERVAL_KEEP);
+    __TASK_INLINE unsigned long getInterval();
+    __TASK_INLINE void setIterations(long aIterations);
+    __TASK_INLINE long getIterations();
+    __TASK_INLINE unsigned long getRunCounter();
     
 #ifdef _TASK_SELF_DESTRUCT
-    _TASK_INLINE void setSelfDestruct(bool aSelfDestruct=true) { iStatus.selfdestruct = aSelfDestruct; }
-    _TASK_INLINE bool getSelfDestruct() { return iStatus.selfdestruct; }
+    __TASK_INLINE void setSelfDestruct(bool aSelfDestruct=true) { iStatus.selfdestruct = aSelfDestruct; }
+    __TASK_INLINE bool getSelfDestruct() { return iStatus.selfdestruct; }
 #endif  //  #ifdef _TASK_SELF_DESTRUCT
 
 #ifdef _TASK_OO_CALLBACKS
-    virtual _TASK_INLINE bool Callback() =0;  // return true if run was "productive - this will disable sleep on the idle run for next pass
-    virtual _TASK_INLINE bool OnEnable();  // return true if task should be enabled, false if it should remain disabled
-    virtual _TASK_INLINE void OnDisable();
+    virtual __TASK_INLINE bool Callback() =0;  // return true if run was "productive - this will disable sleep on the idle run for next pass
+    virtual __TASK_INLINE bool OnEnable();  // return true if task should be enabled, false if it should remain disabled
+    virtual __TASK_INLINE void OnDisable();
 #else
-    _TASK_INLINE void setCallback(TaskCallback aCallback) ;
-    _TASK_INLINE void setOnEnable(TaskOnEnable aCallback) ;
-    _TASK_INLINE void setOnDisable(TaskOnDisable aCallback) ;
-    _TASK_INLINE void yield(TaskCallback aCallback);
-    _TASK_INLINE void yieldOnce(TaskCallback aCallback);
+    __TASK_INLINE void setCallback(TaskCallback aCallback) ;
+    __TASK_INLINE void setOnEnable(TaskOnEnable aCallback) ;
+    __TASK_INLINE void setOnDisable(TaskOnDisable aCallback) ;
+    __TASK_INLINE void yield(TaskCallback aCallback);
+    __TASK_INLINE void yieldOnce(TaskCallback aCallback);
 #endif // _TASK_OO_CALLBACKS
 
-    _TASK_INLINE bool isFirstIteration() ;
-    _TASK_INLINE bool isLastIteration() ;
+    __TASK_INLINE bool isFirstIteration() ;
+    __TASK_INLINE bool isLastIteration() ;
 
 #ifdef _TASK_TIMECRITICAL
-    _TASK_INLINE long getOverrun() ;
-    _TASK_INLINE long getStartDelay() ;
+    __TASK_INLINE long getOverrun() ;
+    __TASK_INLINE long getStartDelay() ;
 #endif  // _TASK_TIMECRITICAL
 
 #ifdef _TASK_STATUS_REQUEST
-    _TASK_INLINE bool waitFor(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
-    _TASK_INLINE bool waitForDelayed(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
-    _TASK_INLINE StatusRequest* getStatusRequest() ;
-    _TASK_INLINE StatusRequest* getInternalStatusRequest() ;
+    __TASK_INLINE bool waitFor(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
+    __TASK_INLINE bool waitForDelayed(StatusRequest* aStatusRequest, unsigned long aInterval = 0, long aIterations = 1);
+    __TASK_INLINE StatusRequest* getStatusRequest() ;
+    __TASK_INLINE StatusRequest* getInternalStatusRequest() ;
 #endif  // _TASK_STATUS_REQUEST
 
 #ifdef _TASK_WDT_IDS
-    _TASK_INLINE void setId(unsigned int aID) ;
-    _TASK_INLINE unsigned int getId() ;
-    _TASK_INLINE void setControlPoint(unsigned int aPoint) ;
-    _TASK_INLINE unsigned int getControlPoint() ;
+    __TASK_INLINE void setId(unsigned int aID) ;
+    __TASK_INLINE unsigned int getId() ;
+    __TASK_INLINE void setControlPoint(unsigned int aPoint) ;
+    __TASK_INLINE unsigned int getControlPoint() ;
 #endif  // _TASK_WDT_IDS
 
 #ifdef _TASK_LTS_POINTER
-    _TASK_INLINE void  setLtsPointer(void *aPtr) ;
-    _TASK_INLINE void* getLtsPointer() ;
+    __TASK_INLINE void  setLtsPointer(void *aPtr) ;
+    __TASK_INLINE void* getLtsPointer() ;
 #endif  // _TASK_LTS_POINTER
 
 #ifdef _TASK_EXPOSE_CHAIN
-    _TASK_INLINE Task*  getPreviousTask() { return iPrev; };  // pointer to the previous task in the chain, NULL if first or not set
-    _TASK_INLINE Task*  getNextTask()     { return iNext; };  // pointer to the next task in the chain, NULL if last or not set
+    __TASK_INLINE Task*  getPreviousTask() { return iPrev; };  // pointer to the previous task in the chain, NULL if first or not set
+    __TASK_INLINE Task*  getNextTask()     { return iNext; };  // pointer to the next task in the chain, NULL if last or not set
 #endif // _TASK_EXPOSE_CHAIN
 
   _TASK_SCOPE:
-    _TASK_INLINE void reset();
+    __TASK_INLINE void reset();
 
     volatile _task_status     iStatus;
     volatile unsigned long    iInterval;             // execution interval in milliseconds (or microseconds). 0 - immediate
@@ -546,72 +546,72 @@ class Task {
 class Scheduler {
   friend class Task;
   public:
-    _TASK_INLINE Scheduler();
+    __TASK_INLINE Scheduler();
 //  ~Scheduler();
-    _TASK_INLINE void init();
-    _TASK_INLINE void addTask(Task& aTask);
-    _TASK_INLINE void deleteTask(Task& aTask);
-    _TASK_INLINE void pause() { iPaused = true; };
-    _TASK_INLINE void resume() { iPaused = false; };
-    _TASK_INLINE void enable() { iEnabled = true; };
-    _TASK_INLINE void disable() { iEnabled = false; };
+    __TASK_INLINE void init();
+    __TASK_INLINE void addTask(Task& aTask);
+    __TASK_INLINE void deleteTask(Task& aTask);
+    __TASK_INLINE void pause() { iPaused = true; };
+    __TASK_INLINE void resume() { iPaused = false; };
+    __TASK_INLINE void enable() { iEnabled = true; };
+    __TASK_INLINE void disable() { iEnabled = false; };
 #ifdef _TASK_PRIORITY
-    _TASK_INLINE void disableAll(bool aRecursive = true);
-    _TASK_INLINE void enableAll(bool aRecursive = true);
-    _TASK_INLINE void startNow(bool aRecursive = true);       // reset ALL active tasks to immediate execution NOW.
+    __TASK_INLINE void disableAll(bool aRecursive = true);
+    __TASK_INLINE void enableAll(bool aRecursive = true);
+    __TASK_INLINE void startNow(bool aRecursive = true);       // reset ALL active tasks to immediate execution NOW.
 #else
-    _TASK_INLINE void disableAll();
-    _TASK_INLINE void enableAll();
-    _TASK_INLINE void startNow();                             // reset ALL active tasks to immediate execution NOW.
+    __TASK_INLINE void disableAll();
+    __TASK_INLINE void enableAll();
+    __TASK_INLINE void startNow();                             // reset ALL active tasks to immediate execution NOW.
 #endif
 
-    _TASK_INLINE bool execute();                              // Returns true if none of the tasks' callback methods was invoked (true = idle run)
+    __TASK_INLINE bool execute();                              // Returns true if none of the tasks' callback methods was invoked (true = idle run)
 
-    _TASK_INLINE Task& currentTask() ;                        // DEPRICATED
-    _TASK_INLINE Task* getCurrentTask() ;                     // Returns pointer to the currently active task
-    _TASK_INLINE long timeUntilNextIteration(Task& aTask);    // return number of ms until next iteration of a given Task
+    __TASK_INLINE Task& currentTask() ;                        // DEPRICATED
+    __TASK_INLINE Task* getCurrentTask() ;                     // Returns pointer to the currently active task
+    __TASK_INLINE long timeUntilNextIteration(Task& aTask);    // return number of ms until next iteration of a given Task
 
-    _TASK_INLINE unsigned long getActiveTasks() { return iActiveTasks; }
-    _TASK_INLINE unsigned long getTotalTasks() { return iTotalTasks; }
-    _TASK_INLINE unsigned long getInvokedTasks() { return iInvokedTasks; }
+    __TASK_INLINE unsigned long getActiveTasks() { return iActiveTasks; }
+    __TASK_INLINE unsigned long getTotalTasks() { return iTotalTasks; }
+    __TASK_INLINE unsigned long getInvokedTasks() { return iInvokedTasks; }
 #ifdef _TASK_TICKLESS
-    _TASK_INLINE unsigned long getNextRun() { return iNextRun; }
+    __TASK_INLINE unsigned long getNextRun() { return iNextRun; }
 #endif
 
 #ifdef _TASK_SLEEP_ON_IDLE_RUN
-    _TASK_INLINE void allowSleep(bool aState = true);
-    _TASK_INLINE void setSleepMethod( SleepCallback aCallback );
+    __TASK_INLINE void allowSleep(bool aState = true);
+    __TASK_INLINE void setSleepMethod( SleepCallback aCallback );
 #endif  // _TASK_SLEEP_ON_IDLE_RUN
 
 #ifdef _TASK_LTS_POINTER
-    _TASK_INLINE void* currentLts();
+    __TASK_INLINE void* currentLts();
 #endif  // _TASK_LTS_POINTER
 
 #ifdef _TASK_TIMECRITICAL
-    _TASK_INLINE bool isOverrun();
-    _TASK_INLINE void cpuLoadReset();
-    _TASK_INLINE unsigned long getCpuLoadCycle(){ return iCPUCycle; };
-    _TASK_INLINE unsigned long getCpuLoadIdle() { return iCPUIdle; };
-    _TASK_INLINE unsigned long getCpuLoadTotal();
+    __TASK_INLINE bool isOverrun();
+    __TASK_INLINE void cpuLoadReset();
+    __TASK_INLINE unsigned long getCpuLoadCycle(){ return iCPUCycle; };
+    __TASK_INLINE unsigned long getCpuLoadIdle() { return iCPUIdle; };
+    __TASK_INLINE unsigned long getCpuLoadTotal();
 #endif  // _TASK_TIMECRITICAL
 
 #ifdef _TASK_PRIORITY
-    _TASK_INLINE void setHighPriorityScheduler(Scheduler* aScheduler);
-    _TASK_INLINE static Scheduler& currentScheduler() { return *(iCurrentScheduler); };
+    __TASK_INLINE void setHighPriorityScheduler(Scheduler* aScheduler);
+    __TASK_INLINE static Scheduler& currentScheduler() { return *(iCurrentScheduler); };
 #endif  // _TASK_PRIORITY
 
 #ifdef _TASK_EXPOSE_CHAIN
-    _TASK_INLINE Task*  getFirstTask() { return iFirst; };       // pointer to the previous task in the chain, NULL if first or not set
-    _TASK_INLINE Task*  getLastTask()  { return iLast;  };       // pointer to the next task in the chain, NULL if last or not set
+    __TASK_INLINE Task*  getFirstTask() { return iFirst; };       // pointer to the previous task in the chain, NULL if first or not set
+    __TASK_INLINE Task*  getLastTask()  { return iLast;  };       // pointer to the next task in the chain, NULL if last or not set
 #endif // _TASK_EXPOSE_CHAIN
 
 #ifdef _TASK_THREAD_SAFE
-    _TASK_INLINE void   requestAction(_task_request_t* aRequest);    // this method places the request on the task request queue
-    _TASK_INLINE void   requestAction(void* aObject, _task_request_type_t aType, unsigned long aParam1, unsigned long aParam2, unsigned long aParam3, unsigned long aParam4, unsigned long aParam5);
+    __TASK_INLINE bool   requestAction(_task_request_t* aRequest);    // this method places the request on the task request queue
+    __TASK_INLINE bool   requestAction(void* aObject, _task_request_type_t aType, unsigned long aParam1, unsigned long aParam2, unsigned long aParam3, unsigned long aParam4, unsigned long aParam5);
 #endif
   _TASK_SCOPE:
 #ifdef _TASK_THREAD_SAFE
-    _TASK_INLINE void   processRequests();
+    __TASK_INLINE void   processRequests();
 #endif
     Task          *iFirst, *iLast, *iCurrent;        // pointers to first, last and current tasks in the chain