File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 1
-
2
1
#include " Schedule.h"
3
2
#include " PolledTimeout.h"
4
3
#ifdef ESP8266
5
4
#include " interrupts.h"
5
+ #include " coredecls.h"
6
6
#else
7
7
#include < mutex>
8
8
#endif
@@ -29,9 +29,9 @@ namespace {
29
29
bool IRAM_ATTR schedule_function_us (std::function<bool (void )>&& fn, uint32_t repeat_us, schedule_e policy)
30
30
{
31
31
scheduled_fn_t item;
32
+ item.policy = policy;
32
33
item.mFunc = std::move (fn);
33
34
if (repeat_us) item.callNow .reset (repeat_us);
34
- item.policy = policy;
35
35
return schedule_queue.push (std::move (item));
36
36
}
37
37
@@ -70,15 +70,24 @@ void run_scheduled_functions(schedule_e policy)
70
70
return ;
71
71
}
72
72
fence = true ;
73
-
74
- // run scheduled function:
75
- // - when its schedule policy allows it anytime
76
- // - or if we are called at loop() time
77
- // and
78
- // - its time policy allows it
79
73
}
80
- schedule_queue.for_each_requeue ([policy](scheduled_fn_t & func)
74
+
75
+ esp8266::polledTimeout::periodicFastMs yieldNow (100 ); // yield every 100ms
76
+
77
+ // run scheduled function:
78
+ // - when its schedule policy allows it anytime
79
+ // - or if we are called at loop() time
80
+ // and
81
+ // - its time policy allows it
82
+ schedule_queue.for_each_requeue ([policy, &yieldNow](scheduled_fn_t & func)
81
83
{
84
+ if (yieldNow) {
85
+ #ifdef ESP8266
86
+ cont_yield (g_pcont);
87
+ #else
88
+ yield ();
89
+ #endif
90
+ }
82
91
return
83
92
(func.policy != SCHEDULE_FUNCTION_WITHOUT_YIELDELAYCALLS && policy != SCHEDULE_FUNCTION_FROM_LOOP)
84
93
|| !func.callNow
You can’t perform that action at this time.
0 commit comments