Struct rayon::ThreadPool
[−]
[src]
pub struct ThreadPool { /* fields omitted */ }
Methods
impl ThreadPool
[src]
fn new(configuration: Configuration) -> Result<ThreadPool, InitError>
Constructs a new thread pool with the given configuration. If
the configuration is not valid, returns a suitable Err
result. See InitError
for more details.
fn install<OP, R>(&self, op: OP) -> R where OP: FnOnce() -> R + Send
Executes op
within the threadpool. Any attempts to join
which occur there will then operate within that threadpool.
fn num_threads(&self) -> usize
Returns the number of threads in the thread pool.
fn current_thread_index(&self) -> Option<usize>
If called from a Rayon worker thread in this thread-pool,
returns the index of that thread; if not called from a Rayon
thread, or called from a Rayon thread that belongs to a
different thread-pool, returns None
.
The index for a given thread will not change over the thread's lifetime. However, multiple threads may share the same index if they are in distinct thread-pools.
Future compatibility note
Currently, every thread-pool (including the global thread-pool) has a fixed number of threads, but this may change in future Rayon versions. In that case, the index for a thread would not change during its lifetime, but thread indices may wind up being reused if threads are terminated and restarted. (If this winds up being an untenable policy, then a semver-incompatible version can be used.)