|
1 | 1 | use super::{ConversionError, Reflection}; |
2 | 2 | use crate::{data_tree::DataTree, size}; |
3 | | -use rayon::prelude::*; |
| 3 | +use orx_parallel::*; |
4 | 4 | use std::{ffi::OsStr, iter::once}; |
5 | 5 |
|
6 | 6 | impl<Name, Size> Reflection<Name, Size> |
7 | 7 | where |
8 | | - Name: Send, |
9 | | - Size: size::Size + Send, |
| 8 | + Name: Send + Sync, |
| 9 | + Size: size::Size + Send + Sync, |
10 | 10 | { |
11 | 11 | /// Attempting to convert a [`Reflection`] into a valid [`DataTree`]. |
12 | 12 | pub fn par_try_into_tree(self) -> Result<DataTree<Name, Size>, ConversionError<Name, Size>> { |
|
25 | 25 | return Err(ConversionError::ExcessiveChildren { path, size, child }); |
26 | 26 | } |
27 | 27 | let children: Result<Vec<_>, _> = children |
28 | | - .into_par_iter() |
| 28 | + .into_par() |
29 | 29 | .map(Self::par_try_into_tree) |
| 30 | + .collect::<Vec<Result<_, _>>>() // TODO: request orx-parallel to make collecting Result possible |
| 31 | + .into_iter() |
30 | 32 | .collect(); |
31 | 33 | let children = match children { |
32 | 34 | Ok(children) => children, |
|
52 | 54 | transform: Transform, |
53 | 55 | ) -> Result<Reflection<TargetName, TargetSize>, Error> |
54 | 56 | where |
55 | | - TargetName: Send, |
| 57 | + TargetName: Send + Sync, |
56 | 58 | TargetSize: size::Size + Send + Sync, |
57 | | - Error: Send, |
| 59 | + Error: Send + Sync, |
58 | 60 | Transform: Fn(Name, Size) -> Result<(TargetName, TargetSize), Error> + Copy + Sync, |
59 | 61 | { |
60 | 62 | let Reflection { |
|
63 | 65 | children, |
64 | 66 | } = self; |
65 | 67 | let children = children |
66 | | - .into_par_iter() |
| 68 | + .into_par() |
67 | 69 | .map(|child| child.par_try_map(transform)) |
| 70 | + .collect::<Vec<Result<_, _>>>() // TODO: request orx-parallel to make collecting Result possible |
| 71 | + .into_iter() |
68 | 72 | .collect::<Result<Vec<_>, _>>()?; |
69 | 73 | let (name, size) = transform(name, size)?; |
70 | 74 | Ok(Reflection { |
|
0 commit comments