Function bevy::tasks::block_on

pub fn block_on<T>(future: impl Future<Output = T>) -> T
Expand description

Blocks the current thread on a future, processing I/O events when idle.

ยงExamples

use async_io::Timer;
use std::time::Duration;

async_io::block_on(async {
    // This timer will likely be processed by the current
    // thread rather than the fallback "async-io" thread.
    Timer::after(Duration::from_millis(1)).await;
});
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);
        }
    }
}