Skip to content

Commit

Permalink
inline more Counter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper authored and nikomatsakis committed Aug 4, 2020
1 parent c3a5304 commit 96ba9ef
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rayon-core/src/sleep/counters.rs
Original file line number Diff line number Diff line change
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 96ba9ef

Please sign in to comment.