Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2757aa2

Browse filesBrowse files
committed
Revert compute_scheduled_recurrent_grain
1 parent d5eb265 commit 2757aa2
Copy full SHA for 2757aa2

File tree

Expand file treeCollapse file tree

3 files changed

+2
-53
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+2
-53
lines changed

‎cores/esp8266/Schedule.cpp

Copy file name to clipboardExpand all lines: cores/esp8266/Schedule.cpp
-35Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
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;
3534
static scheduled_fn_t* sLast = nullptr;
3635
static scheduled_fn_t* sUnused = nullptr;
3736
static int sCount = 0;
38-
static uint32_t recurrent_max_grain_mS = 0;
3937

4038
typedef std::function<bool(void)> mRecFuncT;
4139
struct 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-
168136
void 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
{

‎cores/esp8266/Schedule.h

Copy file name to clipboardExpand all lines: cores/esp8266/Schedule.h
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
// scheduled function happen more often: every yield() (vs every loop()),
4040
// and time resolution is microsecond (vs millisecond). Details are below.
4141

42-
// compute_scheduled_recurrent_grain() is used by delay() to give a chance to
43-
// all recurrent functions to run per their timing requirement.
44-
45-
uint32_t compute_scheduled_recurrent_grain ();
46-
4742
// scheduled functions called once:
4843
//
4944
// * internal queue is FIFO.

‎cores/esp8266/core_esp8266_main.cpp

Copy file name to clipboardExpand all lines: cores/esp8266/core_esp8266_main.cpp
+2-13Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222

2323
//This may be used to change user task stack size:
2424
//#define CONT_STACKSIZE 4096
25-
26-
#include <numeric>
27-
2825
#include <Arduino.h>
2926
#include "Schedule.h"
3027
extern "C" {
@@ -175,16 +172,8 @@ bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uin
175172
if (expired >= timeout_ms) {
176173
return true; // expired
177174
}
178-
179-
// compute greatest chunked delay with respect to scheduled recurrent functions
180-
uint32_t grain_ms = std::gcd(intvl_ms, compute_scheduled_recurrent_grain());
181-
182-
// recurrent scheduled functions will be called from esp_delay()->esp_suspend()
183-
esp_delay(grain_ms > 0 ?
184-
std::min((timeout_ms - expired), grain_ms):
185-
(timeout_ms - expired));
186-
187-
return false; // expiration must be checked again
175+
esp_delay(std::min((timeout_ms - expired), intvl_ms));
176+
return false;
188177
}
189178

190179
extern "C" void __yield() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.