pub struct ParallelPolicy {
pub max_threads: Option<usize>,
pub utility_threshold: usize,
pub postprocess_pixel_threshold: usize,
}Expand description
Centralized configuration for parallel processing behavior across the OCR pipeline.
This struct consolidates parallel processing configuration that was previously scattered across different components, providing a unified way to tune parallelism behavior throughout the OCR pipeline.
Fields§
§max_threads: Option<usize>Maximum number of threads to use for parallel processing. If None, rayon will use the default thread pool size (typically number of CPU cores). Default: None (use rayon’s default)
utility_threshold: usizeThreshold for general utility operations like image loading (<= this uses sequential) Default: 4 (matches DEFAULT_PARALLEL_THRESHOLD constant)
postprocess_pixel_threshold: usizeThreshold for postprocessing operations based on pixel area (<= this uses sequential) Default: 8000 (use sequential for regions with <= 8000 pixels, parallel for larger)
Implementations§
Source§impl ParallelPolicy
impl ParallelPolicy
Sourcepub fn new() -> ParallelPolicy
pub fn new() -> ParallelPolicy
Create a new ParallelPolicy with default values.
Sourcepub fn with_max_threads(self, max_threads: Option<usize>) -> ParallelPolicy
pub fn with_max_threads(self, max_threads: Option<usize>) -> ParallelPolicy
Set the maximum number of threads.
Sourcepub fn with_postprocess_pixel_threshold(
self,
threshold: usize,
) -> ParallelPolicy
pub fn with_postprocess_pixel_threshold( self, threshold: usize, ) -> ParallelPolicy
Set the postprocessing pixel threshold.
Sourcepub fn with_utility_threshold(self, threshold: usize) -> ParallelPolicy
pub fn with_utility_threshold(self, threshold: usize) -> ParallelPolicy
Set the utility operations threshold.
Sourcepub fn install_global_thread_pool(&self) -> Result<bool, ThreadPoolBuildError>
pub fn install_global_thread_pool(&self) -> Result<bool, ThreadPoolBuildError>
Install the global rayon thread pool with the configured number of threads.
This method should be called once at application startup before any parallel
processing occurs. If max_threads is None, this method does nothing and
rayon will use its default thread pool size.
§Returns
Ok(true)if the thread pool was successfully configuredOk(false)ifmax_threadsis None (no configuration needed)Errif the thread pool has already been initialized
§Example
let policy = ParallelPolicy::new().with_max_threads(Some(4));
policy.install_global_thread_pool()?;Trait Implementations§
Source§impl Clone for ParallelPolicy
impl Clone for ParallelPolicy
Source§fn clone(&self) -> ParallelPolicy
fn clone(&self) -> ParallelPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParallelPolicy
impl Debug for ParallelPolicy
Source§impl Default for ParallelPolicy
impl Default for ParallelPolicy
Source§fn default() -> ParallelPolicy
fn default() -> ParallelPolicy
Source§impl<'de> Deserialize<'de> for ParallelPolicy
impl<'de> Deserialize<'de> for ParallelPolicy
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ParallelPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ParallelPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for ParallelPolicy
impl Serialize for ParallelPolicy
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for ParallelPolicy
impl RefUnwindSafe for ParallelPolicy
impl Send for ParallelPolicy
impl Sync for ParallelPolicy
impl Unpin for ParallelPolicy
impl UnsafeUnpin for ParallelPolicy
impl UnwindSafe for ParallelPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.