Function rayon::yield_now

source ·
pub fn yield_now() -> Option<Yield>
Expand description

Cooperatively yields execution to Rayon.

If the current thread is part of a rayon thread pool, this looks for a single unit of pending work in the pool, then executes it. Completion of that work might include nested work or further work stealing.

This is similar to std::thread::yield_now(), but does not literally make that call. If you are implementing a polling loop, you may want to also yield to the OS scheduler yourself if no Rayon work was found.

Returns Some(Yield::Executed) if anything was executed, Some(Yield::Idle) if nothing was available, or None if this thread is not part of any pool at all.