-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multithreaded component refresh #1232
Changes from all commits
c3d8f9e
46a67c8
e202367
03205f2
380ac5c
ba6340c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,33 +1,63 @@ | ||||||
// Take a look at the license at the top of the repository in the LICENSE file. | ||||||
|
||||||
/// Converts the value into a parallel iterator (if the multi-thread feature is enabled). | ||||||
/// Converts the value into a parallel iterator if the `multithread` feature is enabled. | ||||||
/// Uses the `rayon::iter::IntoParallelIterator` trait. | ||||||
#[cfg(all( | ||||||
all( | ||||||
any(target_os = "macos", target_os = "windows", target_os = "freebsd",), | ||||||
feature = "multithread" | ||||||
), | ||||||
feature = "multithread", | ||||||
not(feature = "unknown-ci"), | ||||||
not(all(target_os = "macos", feature = "apple-sandbox")), | ||||||
not(feature = "unknown-ci") | ||||||
))] | ||||||
#[allow(dead_code)] | ||||||
pub(crate) fn into_iter<T>(val: T) -> T::Iter | ||||||
where | ||||||
T: rayon::iter::IntoParallelIterator, | ||||||
{ | ||||||
val.into_par_iter() | ||||||
} | ||||||
|
||||||
/// Converts the value into a sequential iterator (if the multithread feature is disabled). | ||||||
/// Converts the value into a sequential iterator if the `multithread` feature is disabled. | ||||||
/// Uses the `std::iter::IntoIterator` trait. | ||||||
#[cfg(any( | ||||||
not(feature = "multithread"), | ||||||
feature = "unknown-ci", | ||||||
all(target_os = "macos", feature = "apple-sandbox") | ||||||
))] | ||||||
#[allow(dead_code)] | ||||||
pub(crate) fn into_iter<T>(val: T) -> T::IntoIter | ||||||
where | ||||||
T: IntoIterator, | ||||||
{ | ||||||
val.into_iter() | ||||||
} | ||||||
|
||||||
/// Converts the value into a parallel mutable iterator if the `multithread` feature is enabled. | ||||||
/// Uses the `rayon::iter::IntoParallelRefMutIterator` trait. | ||||||
#[cfg(all( | ||||||
all( | ||||||
any(target_os = "macos", target_os = "windows", target_os = "freebsd",), | ||||||
not(feature = "multithread") | ||||||
), | ||||||
feature = "multithread", | ||||||
not(feature = "unknown-ci"), | ||||||
not(all(target_os = "macos", feature = "apple-sandbox")) | ||||||
not(all(target_os = "macos", feature = "apple-sandbox")), | ||||||
))] | ||||||
pub(crate) fn into_iter<T>(val: T) -> T::IntoIter | ||||||
pub(crate) fn into_iter_mut<'a, T>( | ||||||
val: &'a mut T, | ||||||
) -> <T as rayon::iter::IntoParallelRefMutIterator<'a>>::Iter | ||||||
where | ||||||
T: rayon::iter::IntoParallelRefMutIterator<'a> + ?Sized, | ||||||
{ | ||||||
val.par_iter_mut() | ||||||
} | ||||||
|
||||||
// In the multithreaded version of `into_iter_mut` above, the `&mut` on the argument is indicating | ||||||
// the parallel iterator is an exclusive reference. In the non-multithreaded case, the `&mut` is | ||||||
// already part of `T` and specifying it will result in the argument being `&mut &mut T`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, thanks! |
||||||
|
||||||
/// Converts the value into a sequential mutable iterator if the `multithread` feature is disabled. | ||||||
/// Uses the `std::iter::IntoIterator` trait. | ||||||
#[cfg(any( | ||||||
not(feature = "multithread"), | ||||||
feature = "unknown-ci", | ||||||
all(target_os = "macos", feature = "apple-sandbox") | ||||||
))] | ||||||
pub(crate) fn into_iter_mut<T>(val: T) -> T::IntoIter | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be:
Suggested change
to enforce that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is slightly confusing but in the multithreaded case the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a code comment to explain that please? Like that future me will not wonder about it. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. Future me will also appreciate the clarity. |
||||||
where | ||||||
T: IntoIterator, | ||||||
{ | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, great catch!