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>
This commit is contained in:
Angus Gratton 2023-11-30 17:18:15 +11:00 committed by Damien George
parent 393938b3e6
commit c393f5c123
1 changed files with 4 additions and 7 deletions

View File

@ -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__