File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -119,23 +119,33 @@ void run_scheduled_functions()
119
119
{
120
120
esp8266::polledTimeout::periodicFastMs yieldNow (100 ); // yield every 100ms
121
121
122
- while (sFirst )
122
+ // prevent scheduling of new functions during this run
123
+ auto stop = sLast ;
124
+ bool done = false ;
125
+ while (sFirst && !done)
123
126
{
127
+ done = sFirst == stop;
128
+
124
129
sFirst ->mFunc ();
125
130
126
131
{
132
+ // remove function from stack
127
133
esp8266::InterruptLock lockAllInterruptsInThisScope;
128
134
129
135
auto to_recycle = sFirst ;
130
- sFirst = sFirst ->mNext ;
131
- if (!sFirst )
136
+
137
+ // removing rLast
138
+ if (sLast == sFirst )
132
139
sLast = nullptr ;
140
+
141
+ sFirst = sFirst ->mNext ;
142
+
133
143
recycle_fn_unsafe (to_recycle);
134
144
}
135
145
136
146
if (yieldNow)
137
147
{
138
- // because scheduled function are allowed to last:
148
+ // because scheduled functions might last too long for watchdog etc,
139
149
// this is yield() in cont stack:
140
150
esp_schedule ();
141
151
cont_yield (g_pcont);
You can’t perform that action at this time.
0 commit comments