From 2cb4ae3a0678b57eefddcf2ee416aa900c5b9646 Mon Sep 17 00:00:00 2001 From: Mahmut Bulut Date: Sun, 27 Oct 2019 21:47:04 +0100 Subject: [PATCH] Run queue size --- bastion-executor/src/run_queue.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bastion-executor/src/run_queue.rs b/bastion-executor/src/run_queue.rs index 613b3846..f5c60c7b 100644 --- a/bastion-executor/src/run_queue.rs +++ b/bastion-executor/src/run_queue.rs @@ -348,6 +348,15 @@ impl Worker { } } + 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.