Skip to main content

quantrs2_sim/scirs2_integration/
scirs2parallelcontext_traits.rs

1//! # SciRS2ParallelContext - Trait Implementations
2//!
3//! This module contains trait implementations for `SciRS2ParallelContext`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Default`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use scirs2_core::parallel_ops::{
12    current_num_threads, IndexedParallelIterator, ParallelIterator, ThreadPool, ThreadPoolBuilder,
13};
14use scirs2_core::random::prelude::*;
15
16use super::types::SciRS2ParallelContext;
17
18impl Default for SciRS2ParallelContext {
19    fn default() -> Self {
20        let num_threads = current_num_threads();
21        let thread_pool = ThreadPoolBuilder::new()
22            .num_threads(num_threads)
23            .build()
24            .unwrap_or_else(|_| {
25                ThreadPoolBuilder::new()
26                    .build()
27                    .expect("fallback thread pool creation should succeed")
28            });
29        Self {
30            num_threads,
31            thread_pool,
32            numa_aware: true,
33        }
34    }
35}