1#![doc = include_str!("../README.md")]
2#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3#![doc(
4 html_logo_url = "https://bevyengine.org/assets/icon.png",
5 html_favicon_url = "https://bevyengine.org/assets/icon.png"
6)]
7
8mod slice;
9pub use slice::{ParallelSlice, ParallelSliceMut};
10
11mod task;
12pub use task::Task;
13
14#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
15mod task_pool;
16#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
17pub use task_pool::{Scope, TaskPool, TaskPoolBuilder};
18
19#[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))]
20mod single_threaded_task_pool;
21#[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))]
22pub use single_threaded_task_pool::{FakeTask, Scope, TaskPool, TaskPoolBuilder, ThreadExecutor};
23
24mod usages;
25#[cfg(not(target_arch = "wasm32"))]
26pub use usages::tick_global_task_pools_on_main_thread;
27pub use usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool};
28
29#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
30mod thread_executor;
31#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))]
32pub use thread_executor::{ThreadExecutor, ThreadExecutorTicker};
33
34#[cfg(feature = "async-io")]
35pub use async_io::block_on;
36#[cfg(not(feature = "async-io"))]
37pub use futures_lite::future::block_on;
38pub use futures_lite::future::poll_once;
39
40mod iter;
41pub use iter::ParallelIterator;
42
43pub use futures_lite;
44
45#[allow(missing_docs)]
46pub mod prelude {
47 #[doc(hidden)]
48 pub use crate::{
49 block_on,
50 iter::ParallelIterator,
51 slice::{ParallelSlice, ParallelSliceMut},
52 usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool},
53 };
54}
55
56use std::num::NonZeroUsize;
57
58pub fn available_parallelism() -> usize {
65 std::thread::available_parallelism()
66 .map(NonZeroUsize::get)
67 .unwrap_or(1)
68}