[−][src]Struct juggle::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]
F: FnMut() -> bool,
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.
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
[src]
impl Hash for Yield
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
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,
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<F> IntoFuture for F where
F: Future,
[src]
F: Future,
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type Future = F
into_future
)Which kind of future are we turning this into?
fn into_future(self) -> <F as IntoFuture>::Future
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,