linrongbin16
Is it possible to embed `deno_core` with a self-managed event loop?
And the 2nd question is: does the API
deno_core::JsRuntime::run_event_loop
only run 1 tick? or it try to wait everything inside its internal queue to complete?
Because after reading some tutorials and source code of deno_core
, I found there's already some queues inside deno_core
, I guess they're for the queueMicrotask
and built-in async
/await
functions.
For example, if we have below sample code:
Once the deno_core::JsRuntime
execute it, I guess the 1st console.log
will not be printed, instead it's been put in the internal queue and wait for the async readFile
function done. Correct?
Then we call the js_runtime.run_event_loop().await
, once it's completed, is the only 1st console.log
been printed? Or both two console.log
are been printed? i.e. the run_event_loop
API runs for only 1 tick, or wait for all the tasks done?
If it only runs for 1 tick, then I can embed it into my command line TUI application. Because the TUI application is using tokio runtime with the crossterm library. I want to use tokio::select!
on both the crossterm's EventStream
(it receives terminal keyboard/mouse events, such as key pressed, mouse clicked, etc) and the deno_core::JsRuntime::run_event_loop
. Only 1 tick will never block the terminal events.
If it waits for all async tasks done, then it means it cannot work along with the tokio runtime managed by my TUI application. Because it will block the terminal.1 replies
Does V8 engine eventloop/threading model conflict with rust?
hi, I am trying to embed deno's rusty_v8 into rust application.
I am confused about the eventloop/threading model between v8 engine and rust.
because js/ts has the async/await feature (which helps to avoid blocking IO/network, and other things), and v8 engine also has an eventloop itself.
I think when v8 engine is running it's eventloop, it will cause rust main thread blocking?
How should I do to make v8 and rust running together?
3 replies