Function bevy::tasks::poll_once

pub fn poll_once<T, F>(f: F) -> PollOnce<F> 
where F: Future<Output = T>,
Expand description

Polls a future just once and returns an Option with the result.

§Examples

use futures_lite::future;

assert_eq!(future::poll_once(future::pending::<()>()).await, None);
assert_eq!(future::poll_once(future::ready(42)).await, Some(42));
Examples found in repository?
examples/async_tasks/async_compute.rs (line 117)
115
116
117
118
119
120
121
122
fn handle_tasks(mut commands: Commands, mut transform_tasks: Query<&mut ComputeTransform>) {
    for mut task in &mut transform_tasks {
        if let Some(mut commands_queue) = block_on(future::poll_once(&mut task.0)) {
            // append the returned command queue to have it execute later
            commands.append(&mut commands_queue);
        }
    }
}