I'm embedding Duktape into esp32 which runs FreeRTOS.
And I'm stuck with implementing a nonblocking event loop.
As I understood it is pretty trivial to implement an event loop in terms of async-yield. But it is not very nice because it will always load a CPU even if there is nothing really happening except for waiting for the event to occur. I'm thinking about adding another Duktape thread to a Duktape heap where my application is running. And make this separate Duktape thread run by another RTOS task with mutex as sync.
But also there is written that this can lead to issues with garbage collection.
And also as I understand, I will need to take mutex in every native C function that is bound to js functions inside the heap, and that is a little bit inconvenient.
Maybe I miss some simpler way to create such an event loop?
What I need event loop for: execute callback for GUI and run timers. But I need it to sleep when nothing is to do.