@@ -62,7 +62,7 @@ cont_t* g_pcont __attribute__((section(".noinit")));
6262static os_event_t s_loop_queue[LOOP_QUEUE_SIZE];
6363
6464/* Used to implement optimistic_yield */
65- static uint32_t s_cycles_at_yield_start ;
65+ static uint32_t s_cycles_at_resume ;
6666
6767/* For ets_intr_lock_nest / ets_intr_unlock_nest
6868 * Max nesting seen by SDK so far is 2.
@@ -106,41 +106,41 @@ extern "C" void __preloop_update_frequency() {
106106extern " C" void preloop_update_frequency () __attribute__((weak, alias(" __preloop_update_frequency" )));
107107
108108extern " C" bool can_yield () {
109- return cont_can_yield (g_pcont);
109+ return cont_can_suspend (g_pcont);
110110}
111111
112- static inline void esp_yield_within_cont () __attribute__((always_inline));
113- static void esp_yield_within_cont () {
114- cont_yield (g_pcont);
115- s_cycles_at_yield_start = ESP.getCycleCount ();
112+ static inline void esp_suspend_within_cont () __attribute__((always_inline));
113+ static void esp_suspend_within_cont () {
114+ cont_suspend (g_pcont);
115+ s_cycles_at_resume = ESP.getCycleCount ();
116116 run_scheduled_recurrent_functions ();
117117}
118118
119- extern " C" void __esp_yield () {
120- if (can_yield ( )) {
121- esp_yield_within_cont ();
119+ extern " C" void __esp_suspend () {
120+ if (cont_can_suspend (g_pcont )) {
121+ esp_suspend_within_cont ();
122122 }
123123}
124124
125- extern " C" void esp_yield () __attribute__ ((weak, alias(" __esp_yield " )));
125+ extern " C" void esp_suspend () __attribute__ ((weak, alias(" __esp_suspend " )));
126126
127127extern " C" IRAM_ATTR void esp_schedule () {
128128 ets_post (LOOP_TASK_PRIORITY, 0 , 0 );
129129}
130130
131131// Replacement for delay(0). In CONT, same as yield(). Whereas yield() panics
132- // in SYS, esp_break () is safe to call and only schedules CONT. Use yield()
133- // whereever only called from CONT, use esp_break () if code is called from SYS
132+ // in SYS, esp_yield () is safe to call and only schedules CONT. Use yield()
133+ // whereever only called from CONT, use esp_yield () if code is called from SYS
134134// or both CONT and SYS.
135- extern " C" void esp_break () {
135+ extern " C" void esp_yield () {
136136 esp_schedule ();
137- esp_yield ();
137+ esp_suspend ();
138138}
139139
140140extern " C" void __yield () {
141- if (can_yield ( )) {
141+ if (cont_can_suspend (g_pcont )) {
142142 esp_schedule ();
143- esp_yield_within_cont ();
143+ esp_suspend_within_cont ();
144144 }
145145 else {
146146 panic ();
@@ -156,7 +156,7 @@ extern "C" void optimistic_yield(uint32_t interval_us) {
156156#else
157157 ESP.getCpuFreqMHz ();
158158#endif
159- if ((ESP.getCycleCount () - s_cycles_at_yield_start ) > intvl_cycles &&
159+ if ((ESP.getCycleCount () - s_cycles_at_resume ) > intvl_cycles &&
160160 can_yield ())
161161 {
162162 yield ();
@@ -216,7 +216,7 @@ static void loop_wrapper() {
216216
217217static void loop_task (os_event_t *events) {
218218 (void ) events;
219- s_cycles_at_yield_start = ESP.getCycleCount ();
219+ s_cycles_at_resume = ESP.getCycleCount ();
220220 ESP.resetHeap ();
221221 cont_run (g_pcont, &loop_wrapper);
222222 ESP.setDramHeap ();
0 commit comments