Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): clean up timer and promise code (denoland#384)
Deno PR: denoland#21519 Note: `PollEventLoopOptions` was changed so the defaults are now the ones used in the majority of cases. Started working on cleaning up the call_and_await and resolve_value code in JsRuntime. I managed to turn these into pure futures that will resolve independently of the event loop (though still requiring someone to poll it), which means that you can now do something like this: ``` #[op2] fn call(scope: &mut v8::HandleScope, #[global] f: v8::Global<v8::Function>) -> impl Future<...> { JsRuntime::scoped_call(f).await } ``` This should allow for some simplification of any code that's currently using `call_and_await`. `with_event_loop` is split into a "promise" and "future" version. The promise version will throw if the event loop terminates without the promise being resolved. The future version will continue polling until the future resolves (even if the event loop completes). This matches the current behaviour that we are relying on in deno. --------- Co-authored-by: Bartek Iwańczuk <[email protected]>
- Loading branch information