[][src]Struct rustc_rayon_core::Registry

pub struct Registry { /* fields omitted */ }

Methods

impl Registry[src]

pub fn new(
    builder: ThreadPoolBuilder
) -> Result<Arc<Registry>, ThreadPoolBuildError>
[src]

pub fn current() -> Arc<Registry>[src]

pub fn current_num_threads() -> usize[src]

Returns the number of threads in the current registry. This is better than Registry::current().num_threads() because it avoids incrementing the Arc.

pub fn id(&self) -> RegistryId[src]

Returns an opaque identifier for this registry.

pub fn num_threads(&self) -> usize[src]

pub fn handle_panic(&self, err: Box<dyn Any + Send>)[src]

pub fn wait_until_primed(&self)[src]

Waits for the worker threads to get up and running. This is meant to be used for benchmarking purposes, primarily, so that you can get more consistent numbers by having everything "ready to go".

pub fn inject_or_push(&self, job_ref: JobRef)[src]

//////////////////////////////////////////////////////////////////////// MAIN LOOP

So long as all of the worker threads are hanging out in their top-level loop, there is no work to be done. Push a job into the given registry. If we are running on a worker thread for the registry, this will push onto the deque. Else, it will inject from the outside (which is slower).

pub fn inject(&self, injected_jobs: &[JobRef])[src]

Push a job into the "external jobs" queue; it will be taken by whatever worker has nothing to do. Use this is you know that you are not on a worker of this registry.

pub fn in_worker<OP, R>(&self, op: OP) -> R where
    OP: FnOnce(&WorkerThread, bool) -> R + Send,
    R: Send
[src]

If already in a worker-thread of this registry, just execute op. Otherwise, inject op in this thread-pool. Either way, block until op completes and return its return value. If op panics, that panic will be propagated as well. The second argument indicates true if injection was performed, false if executed directly.

pub fn increment_terminate_count(&self)[src]

Increment the terminate counter. This increment should be balanced by a call to terminate, which will decrement. This is used when spawning asynchronous work, which needs to prevent the registry from terminating so long as it is active.

Note that blocking functions such as join and scope do not need to concern themselves with this fn; their context is responsible for ensuring the current thread-pool will not terminate until they return.

The global thread-pool always has an outstanding reference (the initial one). Custom thread-pools have one outstanding reference that is dropped when the ThreadPool is dropped: since installing the thread-pool blocks until any joins/scopes complete, this ensures that joins/scopes are covered.

The exception is ::spawn(), which can create a job outside of any blocking scope. In that case, the job itself holds a terminate count and is responsible for invoking terminate() when finished.

pub fn terminate(&self)[src]

Signals that the thread-pool which owns this registry has been dropped. The worker threads will gradually terminate, once any extant work is completed.

Auto Trait Implementations

impl Send for Registry

impl Sync for Registry

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]