@@ -343,21 +343,23 @@ impl ThreadPool {
343343 /// Cooperatively yields execution to Rayon.
344344 ///
345345 /// This is similar to the general [`yield_now()`], but only if the current
346- /// thread is part of *this* thread pool. Returns `Some(true)` if anything
347- /// was executed, `Some(false)` if nothing was available, or `None` if the
348- /// current thread is not part of this pool.
349- pub fn yield_now ( & self ) -> Option < bool > {
346+ /// thread is part of *this* thread pool.
347+ ///
348+ /// Returns `Some(Yield::Executed)` if anything was executed, `Some(Yield::Idle)` if
349+ /// nothing was available, or `None` if this thread is not part of any pool at all.
350+ pub fn yield_now ( & self ) -> Option < Yield > {
350351 let curr = self . registry . current_thread ( ) ?;
351352 Some ( curr. yield_now ( ) )
352353 }
353354
354355 /// Cooperatively yields execution to local Rayon work.
355356 ///
356357 /// This is similar to the general [`yield_local()`], but only if the current
357- /// thread is part of *this* thread pool. Returns `Some(true)` if anything
358- /// was executed, `Some(false)` if nothing was available, or `None` if the
359- /// current thread is not part of this pool.
360- pub fn yield_local ( & self ) -> Option < bool > {
358+ /// thread is part of *this* thread pool.
359+ ///
360+ /// Returns `Some(Yield::Executed)` if anything was executed, `Some(Yield::Idle)` if
361+ /// nothing was available, or `None` if this thread is not part of any pool at all.
362+ pub fn yield_local ( & self ) -> Option < Yield > {
361363 let curr = self . registry . current_thread ( ) ?;
362364 Some ( curr. yield_local ( ) )
363365 }
@@ -433,9 +435,9 @@ pub fn current_thread_has_pending_tasks() -> Option<bool> {
433435/// that call. If you are implementing a polling loop, you may want to also
434436/// yield to the OS scheduler yourself if no Rayon work was found.
435437///
436- /// Returns `Some(true )` if anything was executed, `Some(false )` if nothing was
437- /// available, or `None` if this thread is not part of any pool at all.
438- pub fn yield_now ( ) -> Option < bool > {
438+ /// Returns `Some(Yield::Executed )` if anything was executed, `Some(Yield::Idle )` if
439+ /// nothing was available, or `None` if this thread is not part of any pool at all.
440+ pub fn yield_now ( ) -> Option < Yield > {
439441 unsafe {
440442 let thread = WorkerThread :: current ( ) . as_ref ( ) ?;
441443 Some ( thread. yield_now ( ) )
@@ -450,11 +452,20 @@ pub fn yield_now() -> Option<bool> {
450452///
451453/// This is similar to [`yield_now()`], but does not steal from other threads.
452454///
453- /// Returns `Some(true )` if anything was executed, `Some(false )` if nothing was
454- /// available, or `None` if this thread is not part of any pool at all.
455- pub fn yield_local ( ) -> Option < bool > {
455+ /// Returns `Some(Yield::Executed )` if anything was executed, `Some(Yield::Idle )` if
456+ /// nothing was available, or `None` if this thread is not part of any pool at all.
457+ pub fn yield_local ( ) -> Option < Yield > {
456458 unsafe {
457459 let thread = WorkerThread :: current ( ) . as_ref ( ) ?;
458460 Some ( thread. yield_local ( ) )
459461 }
460462}
463+
464+ /// Result of [`yield_now()`] or [`yield_local()`].
465+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
466+ pub enum Yield {
467+ /// Work was found and executed.
468+ Executed ,
469+ /// No available work was found.
470+ Idle ,
471+ }
0 commit comments