pub struct LocalExecutor { /* private fields */ }Expand description
A single-threaded executor.
Implementations§
Source§impl LocalExecutor
impl LocalExecutor
Sourcepub fn new(notify: impl Fn() + Send + Sync + 'static) -> LocalExecutor
pub fn new(notify: impl Fn() + Send + Sync + 'static) -> LocalExecutor
Creates a new single-threaded executor.
§Examples
use multitask::LocalExecutor;
let (p, u) = parking::pair();
let ex = LocalExecutor::new(move || u.unpark());Sourcepub fn tick(&self) -> bool
pub fn tick(&self) -> bool
Runs a single task and returns true if one was found.
§Examples
use multitask::LocalExecutor;
let (p, u) = parking::pair();
let ex = LocalExecutor::new(move || u.unpark());
assert!(!ex.tick());
let task = ex.spawn(async { println!("hello") });
// This prints "hello".
assert!(ex.tick());Trait Implementations§
Source§impl Debug for LocalExecutor
impl Debug for LocalExecutor
Source§impl Drop for LocalExecutor
impl Drop for LocalExecutor
impl RefUnwindSafe for LocalExecutor
impl UnwindSafe for LocalExecutor
Auto Trait Implementations§
impl Freeze for LocalExecutor
impl !Send for LocalExecutor
impl !Sync for LocalExecutor
impl Unpin for LocalExecutor
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