From c393f5c12321a80bea40af7ef2e42a077df5d806 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 30 Nov 2023 17:18:15 +1100 Subject: [PATCH] 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 --- ports/windows/mpconfigport.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ports/windows/mpconfigport.h b/ports/windows/mpconfigport.h index 2e1521b9c7..e615fe8502 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__