Skip to content

feat: add advance_event_loop_async #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl Runtime {
}

/// Advance the JS event loop by a single tick
/// See [`Runtime::await_event_loop`] for fully running the event loop
/// See [`Runtime::block_on_event_loop`] for fully running the event loop
///
/// Returns true if the event loop has pending work, or false if it has completed
///
Expand All @@ -173,6 +173,24 @@ impl Runtime {
self.block_on(|runtime| async move { runtime.inner.advance_event_loop(options).await })
}

/// Advance the JS event loop by a single tick
/// See [`Runtime::await_event_loop`] for fully running the event loop
///
/// Returns a future that resolves true if the event loop has pending work, or false if it
/// has completed
///
/// # Arguments
/// * `options` - Options for the event loop polling, see [`deno_core::PollEventLoopOptions`]
///
/// # Errors
/// Can fail if a runtime error occurs during the event loop's execution
pub async fn advance_event_loop_async(
&mut self,
options: PollEventLoopOptions,
) -> Result<bool, Error> {
self.inner.advance_event_loop(options).await
}

/// Run the JS event loop to completion, or until a timeout is reached
/// Required when using the `_immediate` variants of functions
///
Expand Down