Skip to main content

git_same/commands/support/
concurrency.rs

1use crate::operations::clone::MAX_CONCURRENCY;
2use crate::output::Output;
3
4/// Warn if requested concurrency exceeds the maximum.
5/// Returns the effective concurrency to use.
6pub(crate) fn warn_if_concurrency_capped(requested: usize, output: &Output) -> usize {
7    if requested > MAX_CONCURRENCY {
8        output.warn(&format!(
9            "Requested concurrency {} exceeds maximum {}. Using {} instead.",
10            requested, MAX_CONCURRENCY, MAX_CONCURRENCY
11        ));
12        MAX_CONCURRENCY
13    } else {
14        requested
15    }
16}
17
18#[cfg(test)]
19#[path = "concurrency_tests.rs"]
20mod tests;