pub struct Executor(/* private fields */);Expand description
Rust async executor
This is the main interface to the runtime, besides the Worker struct.
What isn’t covered by that struct is covered here.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn new(thread_count: usize) -> Self
pub fn new(thread_count: usize) -> Self
Create a new executor
This creates a new executor with the specified number of threads.
Sourcepub fn spawn_task<T>(
&self,
future: impl Future<Output = T> + Send + 'static,
) -> Option<AsyncTask<'static, T>>
pub fn spawn_task<T>( &self, future: impl Future<Output = T> + Send + 'static, ) -> Option<AsyncTask<'static, T>>
Spawn a task on the executor
Create a new task on the main worker and start it running.
Sourcepub fn create_task<T>(
&self,
future: impl Future<Output = T> + Send + 'static,
) -> Option<AsyncTask<'static, T>>
pub fn create_task<T>( &self, future: impl Future<Output = T> + Send + 'static, ) -> Option<AsyncTask<'static, T>>
Create a task on the executor
Create a task on the main worker
Sourcepub fn timer(&self, duration: Duration) -> impl Future<Output = Instant>
pub fn timer(&self, duration: Duration) -> impl Future<Output = Instant>
Pause execution for the specified duration
This starts a timer on the root worker.
Sourcepub fn start_task<T>(&self, task: &AsyncTask<'_, T>)
pub fn start_task<T>(&self, task: &AsyncTask<'_, T>)
Start a paused task
This starts a paused task on the executor.
Sourcepub fn worker_count(&self) -> usize
pub fn worker_count(&self) -> usize
Worker cardinality
This returns the number of workers on the executor.
Sourcepub fn new_worker(&self) -> Worker
pub fn new_worker(&self) -> Worker
Create a new worker
This creates a new worker on the executor.
Sourcepub fn root_worker(&self) -> Worker
pub fn root_worker(&self) -> Worker
Root worker
This returns the root worker on the executor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Executor
impl RefUnwindSafe for Executor
impl Send for Executor
impl Sync for Executor
impl Unpin for Executor
impl UnwindSafe for Executor
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