Skip to content

Commit 1ab8176

Browse files
committed
mpconfig: Use RUN_BACKGROUND_TASKS as the micropython event hook
This is a newer abstraction in micropython; it'll for instance allow background tasks to be checked once per ms in the internal select module modselect. Because `MICROPY_INTERNAL_EVENT_HOOK` is used in a few locations, our own CIRCUITPY-CHANGE call to `RUN_BACKGROUND_TASKS` can be nixed. Specifically, `mp_event_handle_nowait` calls `MICROPY_INTERNAL_EVENT_HOOK` so paths from it don't need `RUN_BACKGROUND_TASKS` anymore.
1 parent 17bb1eb commit 1ab8176

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

py/circuitpy_mpconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ void background_callback_run_all(void);
452452

453453
#define MICROPY_VM_HOOK_LOOP RUN_BACKGROUND_TASKS;
454454
#define MICROPY_VM_HOOK_RETURN RUN_BACKGROUND_TASKS;
455+
#define MICROPY_INTERNAL_EVENT_HOOK (RUN_BACKGROUND_TASKS)
455456

456457
// CIRCUITPY_AUTORELOAD_DELAY_MS = 0 will completely disable autoreload.
457458
#ifndef CIRCUITPY_AUTORELOAD_DELAY_MS

py/scheduler.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,6 @@ void mp_event_wait_indefinite(void) {
271271
MICROPY_EVENT_POLL_HOOK
272272
#else
273273
mp_event_handle_nowait();
274-
275-
// CIRCUITPY-CHANGE: don't starve CircuitPython background tasks
276-
RUN_BACKGROUND_TASKS;
277-
278274
MICROPY_INTERNAL_WFE(-1);
279275
#endif
280276
}
@@ -287,10 +283,6 @@ void mp_event_wait_ms(mp_uint_t timeout_ms) {
287283
MICROPY_EVENT_POLL_HOOK
288284
#else
289285
mp_event_handle_nowait();
290-
291-
// CIRCUITPY-CHANGE: don't starve CircuitPython background tasks
292-
RUN_BACKGROUND_TASKS;
293-
294286
MICROPY_INTERNAL_WFE(timeout_ms);
295287
#endif
296288
}

0 commit comments

Comments
 (0)