Struct macroquad::experimental::coroutines::Coroutine
source · pub struct Coroutine<T = ()> { /* private fields */ }
Implementations§
source§impl<T: 'static + Any> Coroutine<T>
impl<T: 'static + Any> Coroutine<T>
pub fn retrieve(&self) -> Option<T>
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§
impl<T: Copy> Copy for Coroutine<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Coroutine<T>where
T: RefUnwindSafe,
impl<T> Send for Coroutine<T>where
T: Send,
impl<T> Sync for Coroutine<T>where
T: Sync,
impl<T> Unpin for Coroutine<T>where
T: Unpin,
impl<T> UnwindSafe for Coroutine<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more