fluxus_core/
config.rs

1/// Configuration for parallel processing
2#[derive(Debug, Clone)]
3pub struct ParallelConfig {
4    /// Number of parallel tasks
5    pub parallelism: usize,
6    /// Maximum buffer size per task
7    pub buffer_size: usize,
8    /// Whether to preserve ordering in parallel processing
9    pub preserve_order: bool,
10}
11
12impl Default for ParallelConfig {
13    fn default() -> Self {
14        Self {
15            parallelism: num_cpus::get(),
16            buffer_size: 1000,
17            preserve_order: true,
18        }
19    }
20}
21
22impl ParallelConfig {
23    /// Create a new parallel configuration
24    pub fn new(parallelism: usize, buffer_size: usize, preserve_order: bool) -> Self {
25        Self {
26            parallelism,
27            buffer_size,
28            preserve_order,
29        }
30    }
31
32    /// Set the number of parallel tasks
33    pub fn with_parallelism(mut self, parallelism: usize) -> Self {
34        self.parallelism = parallelism;
35        self
36    }
37
38    /// Set the buffer size per task
39    pub fn with_buffer_size(mut self, buffer_size: usize) -> Self {
40        self.buffer_size = buffer_size;
41        self
42    }
43
44    /// Set whether to preserve ordering
45    pub fn with_preserve_order(mut self, preserve_order: bool) -> Self {
46        self.preserve_order = preserve_order;
47        self
48    }
49}