idle_behavior/
idle_behavior.rs1#![expect(clippy::print_stdout, reason = "Allowed in examples.")]
6
7use bevy_platform::time::Instant;
8use bevy_tasks::TaskPoolBuilder;
9use core::time::Duration;
10
11fn main() {
12 let pool = TaskPoolBuilder::new()
13 .thread_name("Idle Behavior ThreadPool".to_string())
14 .build();
15
16 pool.scope(|s| {
17 for i in 0..1 {
18 s.spawn(async move {
19 println!("Blocking for 10 seconds");
20 let now = Instant::now();
21 while Instant::now() - now < Duration::from_millis(10000) {
22 }
24
25 println!(
26 "Thread {:?} index {} finished",
27 std::thread::current().id(),
28 i
29 );
30 });
31 }
32 });
33
34 println!("all tasks finished");
35}