pub struct Runtime { /* private fields */ }Expand description
The main runtime instance, holds all global state and thread-specific handles are created by it.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new(background_threads: usize) -> Self
pub fn new(background_threads: usize) -> Self
Creates a new runtime with a fixed number of background threads.
Background threads execute tasks that are spawned in the background, allowing foreground threads to keep doing other work.
pub fn handle(&self) -> Handle
Sourcepub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
pub fn spawn<F>(&self, future: F) -> JoinHandle<F::Output> ⓘ
Spawn a future to run in the background. The future can make progress by any participating thread.
If the runtime doesn’t have any background threads, the JoinHandle should be polled/awaited explicitly.
Auto Trait Implementations§
impl !RefUnwindSafe for Runtime
impl !UnwindSafe for Runtime
impl Freeze for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnsafeUnpin for Runtime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more