Struct lunatic_runtime::api::process::EXECUTOR [−][src]
Methods from Deref<Target = TaskExecutor<'static>>
pub fn is_empty(&self) -> bool
Returns true if there are no unfinished tasks.
Examples
use async_executor::Executor; let ex = Executor::new(); assert!(ex.is_empty()); let task = ex.spawn(async { println!("Hello world"); }); assert!(!ex.is_empty()); assert!(ex.try_tick()); assert!(ex.is_empty());
pub fn spawn<T>(&self, future: impl Future<Output = T> + Send + 'a) -> Task<T> where
T: 'a + Send,
T: 'a + Send,
Spawns a task onto the executor.
Examples
use async_executor::Executor; let ex = Executor::new(); let task = ex.spawn(async { println!("Hello world"); });
pub fn try_tick(&self) -> bool
Attempts to run a task if at least one is scheduled.
Running a scheduled task means simply polling its future once.
Examples
use async_executor::Executor; let ex = Executor::new(); assert!(!ex.try_tick()); // no tasks to run let task = ex.spawn(async { println!("Hello world"); }); assert!(ex.try_tick()); // a task was found
pub async fn tick(&'_ self)
Runs a single task.
Running a task means simply polling its future once.
If no tasks are scheduled when this method is called, it will wait until one is scheduled.
Examples
use async_executor::Executor; use futures_lite::future; let ex = Executor::new(); let task = ex.spawn(async { println!("Hello world"); }); future::block_on(ex.tick()); // runs the task
pub async fn run<T>(&'_ self, future: impl Future<Output = T>) -> T
Runs the executor until the given future completes.
Examples
use async_executor::Executor; use futures_lite::future; let ex = Executor::new(); let task = ex.spawn(async { 1 + 2 }); let res = future::block_on(ex.run(async { task.await * 2 })); assert_eq!(res, 6);
Trait Implementations
impl Deref for EXECUTOR[src]
type Target = TaskExecutor<'static>
The resulting type after dereferencing.
fn deref(&self) -> &TaskExecutor<'static>[src]
impl LazyStatic for EXECUTOR[src]
fn initialize(lazy: &Self)[src]
Auto Trait Implementations
impl RefUnwindSafe for EXECUTOR
impl Send for EXECUTOR
impl Sync for EXECUTOR
impl Unpin for EXECUTOR
impl UnwindSafe for EXECUTOR
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,