From b8e5744357966380f2fcb0db2274e7b2c4319210 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:06:37 +0100 Subject: [PATCH] run async tasks as part of the event loop --- crates/dash_rt/src/inspect.rs | 6 +++--- crates/dash_rt/src/runtime.rs | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/dash_rt/src/inspect.rs b/crates/dash_rt/src/inspect.rs index 906b51a0..fd4c6316 100644 --- a/crates/dash_rt/src/inspect.rs +++ b/crates/dash_rt/src/inspect.rs @@ -82,8 +82,8 @@ fn inspect_array_into( Ok(()) } -fn inspect_arraybuffer_into(arraybuffer: &ArrayBuffer, constructor: Symbol, out: &mut String) { - write!(out, "{constructor}({}) {{ ", arraybuffer.len()).unwrap(); +fn inspect_arraybuffer_into(sc: &LocalScope<'_>, arraybuffer: &ArrayBuffer, constructor: Symbol, out: &mut String) { + write!(out, "{}({}) {{ ", sc.interner.resolve(constructor), arraybuffer.len()).unwrap(); for (i, byte) in arraybuffer.storage().iter().enumerate().take(32) { if i > 0 { *out += " "; @@ -158,7 +158,7 @@ fn inspect_inner_into( .extract::(scope) .or_else(|| object.extract::(scope).map(|t| t.arraybuffer(scope))) { - inspect_arraybuffer_into(arraybuffer, constructor_name, out); + inspect_arraybuffer_into(scope, arraybuffer, constructor_name, out); return Ok(()); } diff --git a/crates/dash_rt/src/runtime.rs b/crates/dash_rt/src/runtime.rs index dad263d5..8959d440 100644 --- a/crates/dash_rt/src/runtime.rs +++ b/crates/dash_rt/src/runtime.rs @@ -104,6 +104,8 @@ impl Runtime { } pub async fn run_event_loop(mut self) { + self.vm.process_async_tasks(); + if !self.state().needs_event_loop() { return; } @@ -118,6 +120,7 @@ impl Runtime { } } + self.vm.process_async_tasks(); if !self.state().needs_event_loop() { return; }