vips/concurrency.rs
1//! Concurrency control: package 'vips_concurrency_get/set'
2//!
3//! Reference: <https://www.libvips.org/API/current/libvips-concurrency.html>
4
5/// Get the current concurrency
6///
7/// # Returns
8/// The number of threads currently used by libvips
9///
10/// # Example
11/// ```no_run
12/// use vips::concurrency;
13///
14/// let n = concurrency();
15/// println!("Current libvips concurrency: {}", n);
16/// ```
17pub fn concurrency() -> i32 {
18 unsafe { vips_sys::vips_concurrency_get() }
19}
20
21/// Set concurrency (<=0 will fall back to default)
22///
23/// # Arguments
24/// * `n` - The number of threads to use
25///
26/// # Example
27/// ```no_run
28/// use vips::set_concurrency;
29///
30/// set_concurrency(4);
31/// ```
32pub fn set_concurrency(n: i32) {
33 unsafe { vips_sys::vips_concurrency_set(n) }
34}