Skip to content

Commit 428099d

Browse files
committed
Added yield() method
1 parent 40da8bb commit 428099d

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/ProcessScheduler/Config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <Arduino.h>
55

66
/* Uncomment this to allow Exception Handling functionality */
7-
//#define _PROCESS_EXCEPTION_HANDLING
7+
#define _PROCESS_EXCEPTION_HANDLING
88

99
/* Uncomment this to allow the scheduler to interrupt long running processes */
1010
// This requires _PROCESS_EXCEPTION_HANDLING to also be enabled

src/ProcessScheduler/Process.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class Process
138138
#ifdef _PROCESS_EXCEPTION_HANDLING
139139

140140
protected:
141+
inline void yield() { _scheduler.raiseException(LONGJMP_YIELD_CODE); }
141142
// By default do not handle
142143
virtual bool handleException(int e) { return false; }
143144
virtual void raiseException(int e) { _scheduler.raiseException(e); }

src/ProcessScheduler/Scheduler.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,26 @@ void Scheduler::handleHistOverFlow(uint8_t div)
410410
{
411411
if (e != 0 && _active)
412412
{
413-
if (e == LONGJMP_ISR_CODE)
414-
_active->handleWarning(WARNING_PROC_TIMED_OUT);
415-
else if (!_active->handleException(e))
416-
handleException(*_active, e);
413+
switch(e)
414+
{
415+
#ifdef _PROCESS_TIMEOUT_INTERRUPTS
416+
case LONGJMP_ISR_CODE:
417+
_active->handleWarning(WARNING_PROC_TIMED_OUT);
418+
break;
419+
#endif
420+
case LONGJMP_YIELD_CODE:
421+
//no nothing
422+
break;
423+
424+
default:
425+
if (!_active->handleException(e))
426+
handleException(*_active, e);
427+
break;
417428

429+
}
418430
return true;
419431
}
420432
return false;
421-
422433
}
423434
#endif
424435

0 commit comments

Comments
 (0)