Struct macroquad::experimental::coroutines::Coroutine
source · [−]pub struct Coroutine { /* private fields */ }
Implementations
sourceimpl Coroutine
impl Coroutine
pub fn is_done(&self) -> bool
sourcepub fn set_manual_poll(&mut self)
pub fn set_manual_poll(&mut self)
By default coroutines are being polled each frame, inside the “next_frame()”
start_coroutine(async move {
println!("a");
next_frame().await;
println!("b");
}); // <- coroutine is created, but not yet polled
println!("c"); // <- first print, "c"
next_frame().await; // coroutine will be polled for the first time
// will print "a"
println!("d"); // "d"
next_frame().await; // coroutine will be polled second time, pass next_frame().await and will print "b"
will print “cadb” (there is a test for it, “tests/coroutine.rs:coroutine_execution_order” )
But, sometimes, automatic polling is not nice good example - game pause. Imagine a player that have some “update” function and some coroutines runned. During the pause “update” just early quit, but what with the coroutines?
“set_manual_poll” allows to control how coroutine is beng polled after set_manual_poll() coroutine will never be polled automatically so player will need to poll all its coroutines inside “update” function
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Coroutine
impl Send for Coroutine
impl Sync for Coroutine
impl Unpin for Coroutine
impl UnwindSafe for Coroutine
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
pub fn from_sample_(s: S) -> S
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more