Skip to content

Commit

Permalink
inline more Counter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed May 15, 2020
1 parent f7af261 commit c46b2f7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rayon-core/src/sleep/counters.rs
Expand Up @@ -29,6 +29,7 @@ pub(super) struct JobsEventCounter(usize);
impl JobsEventCounter {
pub(super) const DUMMY: JobsEventCounter = JobsEventCounter(std::usize::MAX);

#[inline]
pub(super) fn as_usize(self) -> usize {
self.0
}
Expand All @@ -37,13 +38,15 @@ impl JobsEventCounter {
/// process of becoming sleepy. This is indicated by its value being *even*.
/// When new jobs are posted, they check if the JEC is sleepy, and if so
/// they incremented it.
#[inline]
pub(super) fn is_sleepy(self) -> bool {
(self.as_usize() & 1) == 0
}

/// The JEC "is active" if the last thread to increment it was posting new
/// work. This is indicated by its value being *odd*. When threads get
/// sleepy, they will check if the JEC is active, and increment it.
#[inline]
pub(super) fn is_active(self) -> bool {
!self.is_sleepy()
}
Expand Down Expand Up @@ -217,6 +220,7 @@ impl Counters {
Counters { word }
}

#[inline]
fn plus(self, word: usize) -> Counters {
Counters {
word: self.word + word,
Expand Down

0 comments on commit c46b2f7

Please sign in to comment.