Skip to content

Commit fc2ef79

Browse files
committed
Optional, for the paranoid: revert changes to (non-recurrent) schedule_function() / run_scheduled_functions().
1 parent 28c0222 commit fc2ef79

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cores/esp8266/Schedule.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static recurrent_fn_t* rLast = &rFirst;
3636
// or if none are available allocates a new one,
3737
// or nullptr if limit is reached
3838
IRAM_ATTR // called from ISR
39-
static scheduled_fn_t* get_fn_unsafe()
39+
static scheduled_fn_t* get_fn_unsafe ()
4040
{
4141
scheduled_fn_t* result = nullptr;
4242
// try to get an item from unused items list
@@ -55,15 +55,15 @@ static scheduled_fn_t* get_fn_unsafe()
5555
return result;
5656
}
5757

58-
static void recycle_fn_unsafe(scheduled_fn_t* fn)
58+
static void recycle_fn_unsafe (scheduled_fn_t* fn)
5959
{
6060
fn->mFunc = nullptr; // special overload in c++ std lib
6161
fn->mNext = sUnused;
6262
sUnused = fn;
6363
}
6464

6565
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)
6767
{
6868
if (!fn)
6969
return false;
@@ -111,7 +111,7 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn, uint32_
111111
return true;
112112
}
113113

114-
void run_scheduled_functions()
114+
void run_scheduled_functions ()
115115
{
116116
esp8266::polledTimeout::periodicFastMs yieldNow(100); // yield every 100ms
117117

@@ -186,10 +186,11 @@ void run_scheduled_recurrent_functions()
186186

187187
auto to_ditch = current;
188188

189+
// removing rLast
190+
if (rLast == current) rLast = prev;
191+
189192
current = current->mNext;
190193
prev->mNext = current;
191-
// removing rLast
192-
if (!current) rLast = prev;
193194

194195
delete(to_ditch);
195196
}

cores/esp8266/Schedule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// * Run the lambda only once next time.
3838
// * A scheduled function can schedule a function.
3939

40-
bool schedule_function(const std::function<void(void)> & fn);
40+
bool schedule_function (const std::function<void(void)>& fn);
4141

4242
// Run all scheduled functions.
4343
// Use this function if your are not using `loop`,

0 commit comments

Comments
 (0)