diff options
author | Laurens Valk <laurens@pybricks.com> | 2021-10-26 10:47:04 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-11-01 15:39:37 +1100 |
commit | fe120484b67bdc114dbbc2b9bd913fab98c82778 (patch) | |
tree | 8e4ed6f1158b2b8c12b48b991c0298cb8065f75a /py/mpconfig.h | |
parent | 693b927687c3ac18726a5eb7b64127fc347a3c41 (diff) |
py/gc: Add hook to run code during time consuming GC operations.
This makes it possible for cooperative multitasking systems to keep running
event loops during garbage collector operations.
For example, this can be used to ensure that a motor control loop runs
approximately each 5 ms. Without this hook, the loop time can jump to
about 15 ms.
Addresses #3475.
Signed-off-by: Laurens Valk <laurens@pybricks.com>
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r-- | py/mpconfig.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h index 596bab8d8..06c46b8c7 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -602,6 +602,11 @@ #define MICROPY_ENABLE_GC (0) #endif +// Hook to run code during time consuming garbage collector operations +#ifndef MICROPY_GC_HOOK_LOOP +#define MICROPY_GC_HOOK_LOOP +#endif + // Whether to enable finalisers in the garbage collector (ie call __del__) #ifndef MICROPY_ENABLE_FINALISER #define MICROPY_ENABLE_FINALISER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) |