DeviceRayonAPI

Trait DeviceRayonAPI 

Source
pub trait DeviceRayonAPI {
    // Required methods
    fn set_num_threads(&mut self, num_threads: usize);
    fn get_num_threads(&self) -> usize;
    fn get_pool(&self) -> &ThreadPool;
    fn get_current_pool(&self) -> Option<&ThreadPool>;
}

Required Methods§

Source

fn set_num_threads(&mut self, num_threads: usize)

Set the number of threads for the device.

Source

fn get_num_threads(&self) -> usize

Get the number of threads for the device.

This function should give the number of threads for the pool. It is not related to whether the current work is done in parallel or serial.

Source

fn get_pool(&self) -> &ThreadPool

Get the thread pool for the device.

Note:

For developers, this function should not be used directly. Instead, use get_current_pool to detect whether using thread pool of its own (Some) or using parent thread pool (None).

Source

fn get_current_pool(&self) -> Option<&ThreadPool>

Get the current thread pool for the device.

  • If in parallel worker, this returns None. This means the program should use the thread pool from the parent. It is important that this does not necessarily means this work should be done in serial.
  • If not in rayon parallel worker, this returns the thread pool.

Implementors§