Skip to main content

parse_with_config_in_pool

Function parse_with_config_in_pool 

Source
pub fn parse_with_config_in_pool<T>(
    input: &str,
    config: &ParserConfig,
    pool: &ThreadPool,
) -> Result<Vec<T>>
where T: DeserializeOwned + Send + 'static,
Expand description

Deserialise every document using a caller-owned Rayon thread pool.

This is the bounded-concurrency entry point for services that must not use Rayon’s global pool. The caller controls the worker count, thread names, stack size, and lifecycle through ThreadPoolBuilder. Small streams still use the same sequential fast path as parse_with_config.

§Errors

Returns the first document or budget error in source order.

§Examples

let pool = noyalib::parallel::ThreadPoolBuilder::new()
    .num_threads(2)
    .build()
    .unwrap();
let yaml = "---\nid: 1\n---\nid: 2\n---\nid: 3\n---\nid: 4\n";
let docs = noyalib::parallel::parse_with_config_in_pool::<noyalib::Value>(
    yaml,
    &noyalib::ParserConfig::default(),
    &pool,
)
.unwrap();
assert_eq!(docs.len(), 4);