[][src]Struct multitask::LocalExecutor

pub struct LocalExecutor { /* fields omitted */ }

A single-threaded executor.

Implementations

impl LocalExecutor[src]

pub fn new(notify: impl Fn() + Send + Sync + 'static) -> LocalExecutor[src]

Creates a new single-threaded executor.

Examples

use multitask::LocalExecutor;

let (p, u) = parking::pair();
let ex = LocalExecutor::new(move || u.unpark());

pub fn spawn<T: 'static>(
    &self,
    future: impl Future<Output = T> + 'static
) -> Task<T>
[src]

Spawns a thread-local future onto this executor.

Returns a Task handle for the spawned future.

Examples

use multitask::LocalExecutor;

let (p, u) = parking::pair();
let ex = LocalExecutor::new(move || u.unpark());

let task = ex.spawn(async { println!("hello") });

pub fn tick(&self) -> bool[src]

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

impl Debug for LocalExecutor[src]

impl Drop for LocalExecutor[src]

impl RefUnwindSafe for LocalExecutor[src]

impl UnwindSafe for LocalExecutor[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.