pub struct Executor<P: Pool = DefaultPool> {
pool: Rc<P>,
park: Arc<P::Park>,
}Expand description
Cooperative executor for local futures; keep it on one core. Higher numbers run first. A continuously ready high-priority task can starve lower priorities.
Fields§
§pool: Rc<P>§park: Arc<P::Park>Implementations§
Source§impl<P: Pool> Executor<P>
impl<P: Pool> Executor<P>
pub fn new(pool: P) -> Self
pub fn spawn_future(&self, future: LocalBoxFuture<'static>) -> TaskHandle
pub fn spawn_boxed( &self, future: impl Future<Output = ()> + 'static, ) -> TaskHandle
pub fn spawn( &self, priority: u16, future: impl Future<Output = ()> + 'static, ) -> TaskHandle
pub fn spawn_future_with_priority( &self, priority: u16, future: LocalBoxFuture<'static>, ) -> TaskHandle
Sourcepub fn poll_once(&self) -> bool
pub fn poll_once(&self) -> bool
Poll one ready task. Returns false when all remaining tasks are sleeping.
Sourcepub fn run_until_stalled(&self)
pub fn run_until_stalled(&self)
Runs until no task is ready; self-waking tasks may keep this running forever.
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for Executor<P>
impl<P> RefUnwindSafe for Executor<P>
impl<P = DefaultPool> !Send for Executor<P>
impl<P = DefaultPool> !Sync for Executor<P>
impl<P> Unpin for Executor<P>
impl<P> UnsafeUnpin for Executor<P>
impl<P> UnwindSafe for Executor<P>
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