Skip to content

Commit

Permalink
Run queue size
Browse files Browse the repository at this point in the history
  • Loading branch information
vertexclique committed Oct 27, 2019
1 parent e41926a commit 2cb4ae3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bastion-executor/src/run_queue.rs
Expand Up @@ -348,6 +348,15 @@ impl<T> Worker<T> {
}
}

pub fn run_queue_size(&self) -> usize {
let b = self.inner.back.load(Ordering::Relaxed);
let f = self.inner.front.load(Ordering::SeqCst);
match b.wrapping_sub(f) {
x if x <= 0 => 0_usize,
y@_ => y as usize
}
}

/// Creates a stealer for this queue.
///
/// The returned stealer can be shared among threads and cloned.
Expand Down

0 comments on commit 2cb4ae3

Please sign in to comment.