summaryrefslogtreecommitdiff
path: root/py/mpconfig.h
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2023-03-15 16:48:16 -0500
committerDamien George <damien@micropython.org>2023-05-09 12:44:14 +1000
commit468ed218c954d34c1cc6affeeff4153b3f16b6b5 (patch)
tree0be7735fd4ef1a2f5c34bcb3342c4945131b1980 /py/mpconfig.h
parent7c645b52e315fa3d63bb95bb42ccf2a9c15fe21d (diff)
py/gc: Make improvements to MICROPY_GC_HOOK_LOOP.
Changes in this commit: - Add MICROPY_GC_HOOK_LOOP to gc_info() and gc_alloc(). Both of these can be long running (many milliseconds) which is too long to be blocking in some applications. - Pass loop variable to MICROPY_GC_HOOK_LOOP(i) macro so that implementers can use it, e.g. to improve performance by only calling a function every X number of iterations. - Drop outer call to MICROPY_GC_HOOK_LOOP in gc_mark_subtree().
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r--py/mpconfig.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 89fb733e9..f3d5ce557 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -617,8 +617,9 @@
#endif
// Hook to run code during time consuming garbage collector operations
+// *i* is the loop index variable (e.g. can be used to run every x loops)
#ifndef MICROPY_GC_HOOK_LOOP
-#define MICROPY_GC_HOOK_LOOP
+#define MICROPY_GC_HOOK_LOOP(i)
#endif
// Whether to provide m_tracked_calloc, m_tracked_free functions