summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2023-11-30 17:18:15 +1100
committerDamien George <damien@micropython.org>2023-12-08 12:49:54 +1100
commitc393f5c12321a80bea40af7ef2e42a077df5d806 (patch)
tree4941aab07df7ec9dea27890fb1637482f7dfe83d
parent393938b3e61ee34b47773766a91a45d3beea6294 (diff)
windows: Implement MICROPY_INTERNAL_WFE() macro.
This should be the equivalent of the previous event poll hook macro. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
-rw-r--r--ports/windows/mpconfigport.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h
index 2e1521b9c..e615fe850 100644
--- a/ports/windows/mpconfigport.h
+++ b/ports/windows/mpconfigport.h
@@ -227,14 +227,11 @@ typedef long mp_off_t;
#include "sleep.h"
#if MICROPY_ENABLE_SCHEDULER
-// Use 1mSec sleep to make sure there is effectively a wait period:
+// Use minimum 1mSec sleep to make sure there is effectively a wait period:
// something like usleep(500) truncates and ends up calling Sleep(0).
-#define MICROPY_EVENT_POLL_HOOK \
- do { \
- extern void mp_handle_pending(bool); \
- mp_handle_pending(true); \
- msec_sleep(1.0); \
- } while (0);
+#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) msec_sleep(MAX(1.0, (double)(TIMEOUT_MS)))
+#else
+#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) /* No-op */
#endif
#ifdef __GNUC__