Skip to content

Commit 453eb2d

Browse files
authored
Add wait loop at the end of mode, refactor can_yield (#6721)
* Add wait loop at the end of mode, refactor can_yield * fix mock build
1 parent 6f7eb28 commit 453eb2d

File tree

4 files changed

+829
-799
lines changed

4 files changed

+829
-799
lines changed

cores/esp8266/core_esp8266_main.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ void preloop_update_frequency() {
9090
#endif
9191
}
9292

93+
extern "C" bool can_yield() {
94+
return cont_can_yield(g_pcont);
95+
}
9396

9497
static inline void esp_yield_within_cont() __attribute__((always_inline));
9598
static void esp_yield_within_cont() {
@@ -98,7 +101,7 @@ static void esp_yield_within_cont() {
98101
}
99102

100103
extern "C" void esp_yield() {
101-
if (cont_can_yield(g_pcont)) {
104+
if (can_yield()) {
102105
esp_yield_within_cont();
103106
}
104107
}
@@ -109,7 +112,7 @@ extern "C" void esp_schedule() {
109112
}
110113

111114
extern "C" void __yield() {
112-
if (cont_can_yield(g_pcont)) {
115+
if (can_yield()) {
113116
esp_schedule();
114117
esp_yield_within_cont();
115118
}
@@ -121,7 +124,7 @@ extern "C" void __yield() {
121124
extern "C" void yield(void) __attribute__ ((weak, alias("__yield")));
122125

123126
extern "C" void optimistic_yield(uint32_t interval_us) {
124-
if (cont_can_yield(g_pcont) &&
127+
if (can_yield() &&
125128
(system_get_time() - s_micros_at_task_start) > interval_us)
126129
{
127130
yield();

cores/esp8266/coredecls.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414

1515
extern bool timeshift64_is_set;
1616

17+
bool can_yield();
1718
void esp_yield();
1819
void esp_schedule();
1920
void tune_timeshift64 (uint64_t now_us);

0 commit comments

Comments
 (0)