Wed, 30 Oct 2024 14:22:06 -0500
Updates for current nightly rust
Cargo.toml | file | annotate | diff | comparison | revisions | |
src/lib.rs | file | annotate | diff | comparison | revisions | |
src/parallelism.rs | file | annotate | diff | comparison | revisions |
--- a/Cargo.toml Fri Oct 13 14:15:56 2023 -0500 +++ b/Cargo.toml Wed Oct 30 14:22:06 2024 -0500 @@ -31,3 +31,7 @@ [profile.release] debug = true + +[features] +default = [] +use_custom_thread_pool = []
--- a/src/lib.rs Fri Oct 13 14:15:56 2023 -0500 +++ b/src/lib.rs Wed Oct 30 14:22:06 2024 -0500 @@ -10,10 +10,6 @@ #![feature(maybe_uninit_uninit_array,maybe_uninit_array_assume_init,maybe_uninit_slice)] #![feature(try_trait_v2_residual,try_trait_v2)] -#![feature(array_methods)] - -#![feature(arc_unwrap_or_clone)] - #![feature(float_minimum_maximum)] #![feature(get_mut_unchecked)]
--- a/src/parallelism.rs Fri Oct 13 14:15:56 2023 -0500 +++ b/src/parallelism.rs Wed Oct 30 14:22:06 2024 -0500 @@ -16,9 +16,9 @@ Ordering::{Release, Relaxed}, }; -#[cfg(use_custom_thread_pool)] +#[cfg(feature = "use_custom_thread_pool")] type Pool = ThreadPool; -#[cfg(not(use_custom_thread_pool))] +#[cfg(not(feature = "use_custom_thread_pool"))] type Pool = GlobalPool; const ONE : NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(1) }; @@ -27,12 +27,12 @@ static mut POOL : Option<Pool> = None; static INIT: Once = Once::new(); -#[cfg(not(use_custom_thread_pool))] +#[cfg(not(feature = "use_custom_thread_pool"))] mod global_pool { /// This is a nicer way to use the global pool of [`rayon`]. pub struct GlobalPool; - #[cfg(not(use_custom_thread_pool))] + #[cfg(not(feature = "use_custom_thread_pool"))] impl GlobalPool { #[inline] pub fn scope<'scope, OP, R>(&self, op: OP) -> R @@ -44,7 +44,7 @@ } } -#[cfg(not(use_custom_thread_pool))] +#[cfg(not(feature = "use_custom_thread_pool"))] pub use global_pool::GlobalPool; /// Set the number of threads. @@ -57,10 +57,10 @@ let n = n.get(); set_task_overbudgeting((n + 1) / 2); POOL = if n > 1 { - #[cfg(use_custom_thread_pool)] { + #[cfg(feature = "use_custom_thread_pool")] { Some(ThreadPoolBuilder::new().num_threads(n).build().unwrap()) } - #[cfg(not(use_custom_thread_pool))] { + #[cfg(not(feature = "use_custom_thread_pool"))] { ThreadPoolBuilder::new().num_threads(n).build_global().unwrap(); Some(GlobalPool) } @@ -75,6 +75,7 @@ /// The initial value is 1. Calling [`set_num_threads`] sets this to $m = (n + 1) / 2$, where /// $n$ is the number of threads. pub fn set_task_overbudgeting(m : usize) { + #[allow(static_mut_refs)] unsafe { TASK_OVERBUDGETING.store(m, Relaxed) } } @@ -97,6 +98,7 @@ /// If the number of configured threads is less than 2, this is None. /// The pool has [`num_threads`]` - 1` threads. pub fn thread_pool() -> Option<&'static Pool> { + #[allow(static_mut_refs)] unsafe { POOL.as_ref() } } @@ -146,6 +148,7 @@ /// is `None`, the [global setting][set_task_overbudgeting] is used.ยง pub fn init(overbudget : Option<usize>) -> Self { let n = num_threads().get(); + #[allow(static_mut_refs)] let m = overbudget.unwrap_or_else(|| unsafe { TASK_OVERBUDGETING.load(Relaxed) }); if n <= 1 { Self::SingleThreaded