[][src]Struct juggle::Yield

pub struct Yield(_);

Helper struct for dealing with task switching.

Implementations

impl Yield[src]

pub fn once() -> Self[src]

When awaited yields this task once. Causes task switch.

For more convenient method of switching tasks see yield_once!() macro.

When resulting Future is polled, for the first time it notifies the waker and returns Poll::Pending, second and all other polls return Poll::Ready(()).

pub fn none() -> Self[src]

When awaited it won't cause task switch.

Future returned by this method when polled always return Poll::Ready(()).

pub fn times(remaining: usize) -> YieldTimes[src]

When awaited yields this task specific number of times.

Resulting Future notifies the waker and returns Poll::Pending 'remaining' number of times, all other polls return Poll::Ready(()).

pub fn yield_while<F>(predicate: F) -> YieldWhile<F> where
    F: FnMut() -> bool
[src]

When awaited yields this task until provided closure returns false.

Note that when first call on closure returns false, this task will not be yielded. This method is usefull when we want to do busy wait but also leave cpu time for other tasks.

Examples

let interrupt_flag: &AtomicBool = //...

Yield::yield_while(||!interrupt_flag.load(Ordering::Acquire)).await;

Trait Implementations

impl Clone for Yield[src]

impl Debug for Yield[src]

impl Eq for Yield[src]

impl Future for Yield[src]

type Output = ()

The type of value produced on completion.

impl Hash for Yield[src]

impl PartialEq<Yield> for Yield[src]

impl StructuralEq for Yield[src]

impl StructuralPartialEq for Yield[src]

Auto Trait Implementations

impl RefUnwindSafe for Yield

impl Send for Yield

impl Sync for Yield

impl Unpin for Yield

impl UnwindSafe for Yield

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<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.