mirror of
https://github.com/bevyengine/bevy
synced 2024-12-21 02:23:08 +00:00
694c06f3d0
# Objective Currently the `missing_docs` lint is allowed-by-default and enabled at crate level when their documentations is complete (see #3492). This PR proposes to inverse this logic by making `missing_docs` warn-by-default and mark crates with imcomplete docs allowed. ## Solution Makes `missing_docs` warn at workspace level and allowed at crate level when the docs is imcomplete.
34 lines
1 KiB
Rust
34 lines
1 KiB
Rust
//! This sample demonstrates creating a thread pool with 4 tasks and spawning 40 tasks that spin
|
|
//! for 100ms. It's expected to take about a second to run (assuming the machine has >= 4 logical
|
|
//! cores)
|
|
|
|
use bevy_tasks::TaskPoolBuilder;
|
|
use web_time::{Duration, Instant};
|
|
|
|
fn main() {
|
|
let pool = TaskPoolBuilder::new()
|
|
.thread_name("Busy Behavior ThreadPool".to_string())
|
|
.num_threads(4)
|
|
.build();
|
|
|
|
let t0 = Instant::now();
|
|
pool.scope(|s| {
|
|
for i in 0..40 {
|
|
s.spawn(async move {
|
|
let now = Instant::now();
|
|
while Instant::now() - now < Duration::from_millis(100) {
|
|
// spin, simulating work being done
|
|
}
|
|
|
|
println!(
|
|
"Thread {:?} index {} finished",
|
|
std::thread::current().id(),
|
|
i
|
|
);
|
|
});
|
|
}
|
|
});
|
|
|
|
let t1 = Instant::now();
|
|
println!("all tasks finished in {} secs", (t1 - t0).as_secs_f32());
|
|
}
|