2022-01-16 04:53:22 +00:00
|
|
|
#![warn(missing_docs)]
|
2021-12-18 22:59:55 +00:00
|
|
|
#![doc = include_str!("../README.md")]
|
|
|
|
|
2020-08-29 19:35:41 +00:00
|
|
|
mod slice;
|
|
|
|
pub use slice::{ParallelSlice, ParallelSliceMut};
|
|
|
|
|
|
|
|
mod task;
|
|
|
|
pub use task::Task;
|
|
|
|
|
2020-09-16 01:05:31 +00:00
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
2020-08-29 19:35:41 +00:00
|
|
|
mod task_pool;
|
2020-09-16 01:05:31 +00:00
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
2020-08-29 19:35:41 +00:00
|
|
|
pub use task_pool::{Scope, TaskPool, TaskPoolBuilder};
|
|
|
|
|
2020-09-16 01:05:31 +00:00
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
mod single_threaded_task_pool;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
pub use single_threaded_task_pool::{Scope, TaskPool, TaskPoolBuilder};
|
|
|
|
|
2020-08-29 19:35:41 +00:00
|
|
|
mod usages;
|
2020-09-22 03:23:09 +00:00
|
|
|
pub use usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool};
|
2020-08-29 19:35:41 +00:00
|
|
|
|
2020-09-08 19:18:32 +00:00
|
|
|
mod iter;
|
|
|
|
pub use iter::ParallelIterator;
|
|
|
|
|
2022-01-16 04:53:22 +00:00
|
|
|
#[allow(missing_docs)]
|
2020-08-29 19:35:41 +00:00
|
|
|
pub mod prelude {
|
2021-04-27 18:29:33 +00:00
|
|
|
#[doc(hidden)]
|
2020-08-29 19:35:41 +00:00
|
|
|
pub use crate::{
|
2020-09-08 19:18:32 +00:00
|
|
|
iter::ParallelIterator,
|
2020-08-29 19:35:41 +00:00
|
|
|
slice::{ParallelSlice, ParallelSliceMut},
|
2020-09-22 03:23:09 +00:00
|
|
|
usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool},
|
2020-08-29 19:35:41 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-09-19 15:46:03 +00:00
|
|
|
use std::num::NonZeroUsize;
|
|
|
|
|
|
|
|
/// Gets the logical CPU core count available to the current process.
|
|
|
|
///
|
|
|
|
/// This is identical to [`std::thread::available_parallelism`], except
|
|
|
|
/// it will return a default value of 1 if it internally errors out.
|
|
|
|
///
|
|
|
|
/// This will always return at least 1.
|
|
|
|
pub fn available_parallelism() -> usize {
|
|
|
|
std::thread::available_parallelism()
|
|
|
|
.map(NonZeroUsize::get)
|
|
|
|
.unwrap_or(1)
|
|
|
|
}
|