1717*/
1818
1919#include < assert.h>
20- #include < numeric>
2120
2221#include " Schedule.h"
2322#include " PolledTimeout.h"
@@ -35,7 +34,6 @@ static scheduled_fn_t* sFirst = nullptr;
3534static scheduled_fn_t * sLast = nullptr ;
3635static scheduled_fn_t * sUnused = nullptr ;
3736static int sCount = 0 ;
38- static uint32_t recurrent_max_grain_mS = 0 ;
3937
4038typedef std::function<bool (void )> mRecFuncT ;
4139struct recurrent_fn_t
@@ -132,39 +130,9 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
132130 }
133131 rLast = item;
134132
135- // grain needs to be recomputed
136- recurrent_max_grain_mS = 0 ;
137-
138133 return true ;
139134}
140135
141- uint32_t compute_scheduled_recurrent_grain ()
142- {
143- if (recurrent_max_grain_mS == 0 )
144- {
145- if (rFirst)
146- {
147- uint32_t recurrent_max_grain_uS = rFirst->callNow .getTimeout ();
148- for (auto it = rFirst->mNext ; it; it = it->mNext )
149- recurrent_max_grain_uS = std::gcd (recurrent_max_grain_uS, it->callNow .getTimeout ());
150- if (recurrent_max_grain_uS)
151- // round to the upper millis
152- recurrent_max_grain_mS = recurrent_max_grain_uS <= 1000 ? 1 : (recurrent_max_grain_uS + 999 ) / 1000 ;
153- }
154-
155- #ifdef DEBUG_ESP_CORE
156- static uint32_t last_grain = 0 ;
157- if (recurrent_max_grain_mS != last_grain)
158- {
159- ::printf (" :rsf %u->%u\n " , last_grain, recurrent_max_grain_mS);
160- last_grain = recurrent_max_grain_mS;
161- }
162- #endif
163- }
164-
165- return recurrent_max_grain_mS;
166- }
167-
168136void run_scheduled_functions ()
169137{
170138 // prevent scheduling of new functions during this run
@@ -258,9 +226,6 @@ void run_scheduled_recurrent_functions()
258226 }
259227
260228 delete (to_ditch);
261-
262- // grain needs to be recomputed
263- recurrent_max_grain_mS = 0 ;
264229 }
265230 else
266231 {
0 commit comments