@@ -36,7 +36,7 @@ static recurrent_fn_t* rLast = &rFirst;
36
36
// or if none are available allocates a new one,
37
37
// or nullptr if limit is reached
38
38
IRAM_ATTR // called from ISR
39
- static scheduled_fn_t * get_fn_unsafe ()
39
+ static scheduled_fn_t * get_fn_unsafe ()
40
40
{
41
41
scheduled_fn_t * result = nullptr ;
42
42
// try to get an item from unused items list
@@ -55,15 +55,15 @@ static scheduled_fn_t* get_fn_unsafe()
55
55
return result;
56
56
}
57
57
58
- static void recycle_fn_unsafe (scheduled_fn_t * fn)
58
+ static void recycle_fn_unsafe (scheduled_fn_t * fn)
59
59
{
60
60
fn->mFunc = nullptr ; // special overload in c++ std lib
61
61
fn->mNext = sUnused ;
62
62
sUnused = fn;
63
63
}
64
64
65
65
IRAM_ATTR // (not only) called from ISR
66
- bool schedule_function (const std::function<void (void )>& fn)
66
+ bool schedule_function (const std::function<void (void )>& fn)
67
67
{
68
68
if (!fn)
69
69
return false ;
@@ -111,7 +111,7 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn, uint32_
111
111
return true ;
112
112
}
113
113
114
- void run_scheduled_functions ()
114
+ void run_scheduled_functions ()
115
115
{
116
116
esp8266::polledTimeout::periodicFastMs yieldNow (100 ); // yield every 100ms
117
117
@@ -186,10 +186,11 @@ void run_scheduled_recurrent_functions()
186
186
187
187
auto to_ditch = current;
188
188
189
+ // removing rLast
190
+ if (rLast == current) rLast = prev;
191
+
189
192
current = current->mNext ;
190
193
prev->mNext = current;
191
- // removing rLast
192
- if (!current) rLast = prev;
193
194
194
195
delete (to_ditch);
195
196
}
0 commit comments