pub struct Runtime { /* private fields */ }Implementations§
Source§impl Runtime
impl Runtime
pub fn new() -> Self
pub fn new_with_threads(num_os_threads: NonZeroUsize) -> Self
Sourcepub fn block_on<T: Send + 'static, F: Future<Output = T> + Send + 'static>(
&self,
task: F,
) -> T
pub fn block_on<T: Send + 'static, F: Future<Output = T> + Send + 'static>( &self, task: F, ) -> T
Blocks the current thread until the runtime has finished th task
Sourcepub unsafe fn unsafe_block_on<T: Send + 'static, F: Future<Output = T> + 'static>(
&self,
task: F,
) -> T
pub unsafe fn unsafe_block_on<T: Send + 'static, F: Future<Output = T> + 'static>( &self, task: F, ) -> T
Blocks the current thread until the runtime has finished th task (unsafe version)
§Safety
Make sure task is Send before polled for the first time (Can be not Send afterwards)
Sourcepub fn spawn<F: Future<Output = ()> + Send + 'static>(&self, task: F)
pub fn spawn<F: Future<Output = ()> + Send + 'static>(&self, task: F)
Spawns the task on a random thread
Sourcepub fn get_num_threads(&self) -> usize
pub fn get_num_threads(&self) -> usize
How many worker threads are there?
Sourcepub fn spawn_at<F: Future<Output = ()> + Send + 'static>(
&self,
offset: usize,
task: F,
)
pub fn spawn_at<F: Future<Output = ()> + Send + 'static>( &self, offset: usize, task: F, )
Spawns the task on a specific thread
Sourcepub unsafe fn unsafe_spawn_at<F: Future<Output = ()> + 'static>(
&self,
offset: usize,
task: F,
)
pub unsafe fn unsafe_spawn_at<F: Future<Output = ()> + 'static>( &self, offset: usize, task: F, )
§Safety
Make sure task is Send before polled for the first time (Can be not Send afterwards)
Sourcepub unsafe fn unsafe_spawn<F: Future<Output = ()> + 'static>(&self, task: F)
pub unsafe fn unsafe_spawn<F: Future<Output = ()> + 'static>(&self, task: F)
§Safety
Make sure task is Send before polled for the first time (Can be not Send afterwards)
Sourcepub fn new_spawn_ring(&self) -> SpawnRing
pub fn new_spawn_ring(&self) -> SpawnRing
Create a primitive that lets you distribute tasks across worker threads in a round-robin fashion
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Runtime
impl !RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl !UnwindSafe 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