orx_parallel/parameters/
params.rs1use super::{chunk_size::ChunkSize, iteration_order::IterationOrder, num_threads::NumThreads};
2
3#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
5pub struct Params {
6 pub num_threads: NumThreads,
10 pub chunk_size: ChunkSize,
14 pub iteration_order: IterationOrder,
19}
20
21impl Params {
22 pub fn new(
24 num_threads: impl Into<NumThreads>,
25 chunk_size: impl Into<ChunkSize>,
26 iteration_order: IterationOrder,
27 ) -> Self {
28 Self {
29 num_threads: num_threads.into(),
30 chunk_size: chunk_size.into(),
31 iteration_order,
32 }
33 }
34
35 pub fn is_sequential(self) -> bool {
39 self.num_threads.is_sequential()
40 }
41
42 pub(crate) fn with_num_threads(self, num_threads: impl Into<NumThreads>) -> Self {
45 Self {
46 num_threads: num_threads.into(),
47 chunk_size: self.chunk_size,
48 iteration_order: self.iteration_order,
49 }
50 }
51
52 pub(crate) fn with_chunk_size(self, chunk_size: impl Into<ChunkSize>) -> Self {
53 Self {
54 num_threads: self.num_threads,
55 chunk_size: chunk_size.into(),
56 iteration_order: self.iteration_order,
57 }
58 }
59
60 pub(crate) fn with_collect_ordering(self, iteration_order: IterationOrder) -> Self {
61 Self {
62 num_threads: self.num_threads,
63 chunk_size: self.chunk_size,
64 iteration_order,
65 }
66 }
67}