Added an early return to `put_and_try_run`
@@ -49,7 +49,10 @@ impl Scheduler {
pub(crate) fn put_and_try_run(&self, runnable: Box<dyn Runnable>) {
self.sequence.borrow_mut().push_back(runnable);
- if self.lock.compare_and_swap(false, true, Ordering::Relaxed) == false {
+ if self.lock.compare_and_swap(false, true, Ordering::Relaxed) {
+ return;
+ }
+
loop {
let do_next = self.sequence.borrow_mut().pop_front();
if let Some(runnable) = do_next {
@@ -61,4 +64,3 @@ impl Scheduler {
self.lock.store(false, Ordering::Relaxed);
}
}
-}
