This works by essentially bolting a custom Rust futures executor onto Nodejs's event loop triggered via a thread safe function.
The futures executor yields back to JavaScript execution as soon as it hits a pending Future, later resuming when woken up by a future that has work to do.
This means that the Rust "event loop" will never block Nodejs's event loop and vice versa.
For channels, sleep, and other common async tasks, utilities from async-std can be used.
Tokio is not suitable for this use case as it's designed to be the only executor running and cannot be driven (or at least I cannot figure out how to drive it) from an external event loop.
This PR introduces Rust future execution concurrently on the local thread without blocking JavaScript execution.
It's still a work in progress, requesting comments for ways I can improve the implementation if it's a good candidate for contribution.
Examples
Async Function Declaration
Simple Async
Declare an async function that returns a promise and does not block the main thread.
Async MPSC Channel
Function Async Closure
How does this work? Tokio?
This works by essentially bolting a custom Rust futures executor onto Nodejs's event loop triggered via a thread safe function.
The futures executor yields back to JavaScript execution as soon as it hits a pending Future, later resuming when woken up by a future that has work to do.
This means that the Rust "event loop" will never block Nodejs's event loop and vice versa.
For channels, sleep, and other common async tasks, utilities from async-std can be used.
Tokio is not suitable for this use case as it's designed to be the only executor running and cannot be driven (or at least I cannot figure out how to drive it) from an external event loop.
TODO: [] Tests [] Error handing [] Documentation [] Missing functionality