Struct rustc_rayon_core::Registry[][src]

pub struct Registry { /* fields omitted */ }

Methods

impl Registry
[src]

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

Returns an opaque identifier for this registry.

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".

//////////////////////////////////////////////////////////////////////// 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).

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.

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.

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.

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