@@ -343,21 +343,23 @@ impl ThreadPool {
343
343
/// Cooperatively yields execution to Rayon.
344
344
///
345
345
/// 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 > {
350
351
let curr = self . registry . current_thread ( ) ?;
351
352
Some ( curr. yield_now ( ) )
352
353
}
353
354
354
355
/// Cooperatively yields execution to local Rayon work.
355
356
///
356
357
/// 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 > {
361
363
let curr = self . registry . current_thread ( ) ?;
362
364
Some ( curr. yield_local ( ) )
363
365
}
@@ -433,9 +435,9 @@ pub fn current_thread_has_pending_tasks() -> Option<bool> {
433
435
/// that call. If you are implementing a polling loop, you may want to also
434
436
/// yield to the OS scheduler yourself if no Rayon work was found.
435
437
///
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 > {
439
441
unsafe {
440
442
let thread = WorkerThread :: current ( ) . as_ref ( ) ?;
441
443
Some ( thread. yield_now ( ) )
@@ -450,11 +452,20 @@ pub fn yield_now() -> Option<bool> {
450
452
///
451
453
/// This is similar to [`yield_now()`], but does not steal from other threads.
452
454
///
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 > {
456
458
unsafe {
457
459
let thread = WorkerThread :: current ( ) . as_ref ( ) ?;
458
460
Some ( thread. yield_local ( ) )
459
461
}
460
462
}
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