Function rayon::current_num_threads

source ·
pub fn current_num_threads() -> usize
Expand description

Returns the number of threads in the current registry. If this code is executing within a Rayon thread-pool, then this will be the number of threads for the thread-pool of the current thread. Otherwise, it will be the number of threads for the global thread-pool.

This can be useful when trying to judge how many times to split parallel work (the parallel iterator traits use this value internally for this purpose).

Future compatibility note

Note that unless this thread-pool was created with a builder that specifies the number of threads, then this number may vary over time in future versions (see the num_threads() method for details).