diff --git a/src/lib.rs b/src/lib.rs index 74962405..5d675ead 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -78,7 +78,7 @@ pub mod buf; pub mod fs; pub mod net; -pub use runtime::spawn; +pub use runtime::{spawn, Runtime}; use std::future::Future; diff --git a/src/runtime.rs b/src/runtime.rs index 4b05ad41..97f56d4d 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -6,7 +6,8 @@ use std::io; use tokio::io::unix::AsyncFd; use tokio::task::LocalSet; -pub(crate) struct Runtime { +/// The tokio-uring runtime based on the Tokio current thread runtime. +pub struct Runtime { /// io-uring driver driver: AsyncFd, @@ -50,7 +51,8 @@ pub fn spawn(task: T) -> tokio::task::JoinHand } impl Runtime { - pub(crate) fn new() -> io::Result { + /// Create a new tokio-uring [Runtime] object. + pub fn new() -> io::Result { let rt = tokio::runtime::Builder::new_current_thread() .on_thread_park(|| { CURRENT.with(|x| { @@ -70,7 +72,12 @@ impl Runtime { Ok(Runtime { driver, local, rt }) } - pub(crate) fn block_on(&mut self, future: F) -> F::Output + /// Runs a future to completion on the Tokio-uring runtime. + /// + /// This runs the given future on the current thread, blocking until it is + /// complete, and yielding its resolved result. Any tasks or timers + /// which the future spawns internally will be executed on the runtime. + pub fn block_on(&mut self, future: F) -> F::Output where F: Future, {