diff --git a/src/actor/tests.rs b/src/actor/tests.rs index 67ff78ab..3b9b5451 100644 --- a/src/actor/tests.rs +++ b/src/actor/tests.rs @@ -120,7 +120,7 @@ fn actor_future() { // Send a message and the actor should return Ok. actor_ref.try_send(()).unwrap(); - assert_eq!(count.load(Ordering::SeqCst), 1); + assert_eq!(count.load(Ordering::Acquire), 1); let res = actor.as_mut().poll(&mut ctx); assert_eq!(res, Poll::Ready(())); } @@ -150,7 +150,7 @@ fn erroneous_actor_process() { let res = actor.as_mut().poll(&mut ctx); assert_eq!(res, Poll::Ready(())); assert_eq!(supervisor_called_count, 1); - assert_eq!(count.load(Ordering::SeqCst), 0); + assert_eq!(count.load(Ordering::Acquire), 0); } #[test] @@ -170,7 +170,7 @@ fn restarting_erroneous_actor_process() { assert_eq!(res, Poll::Pending); assert_eq!(supervisor_called_count.get(), 1); // The future to wake itself after a restart to ensure it gets run again. - assert_eq!(count.load(Ordering::SeqCst), 1); + assert_eq!(count.load(Ordering::Acquire), 1); // After a restart the actor should continue without issues. let res = actor.as_mut().poll(&mut ctx); @@ -179,7 +179,7 @@ fn restarting_erroneous_actor_process() { // Finally after sending it a message it should complete. actor_ref.try_send(()).unwrap(); - assert_eq!(count.load(Ordering::SeqCst), 2); + assert_eq!(count.load(Ordering::Acquire), 2); let res = actor.as_mut().poll(&mut ctx); assert_eq!(res, Poll::Ready(())); assert_eq!(supervisor_called_count.get(), 1); @@ -237,7 +237,7 @@ fn panicking_actor_process() { let res = actor.as_mut().poll(&mut ctx); assert_eq!(res, Poll::Ready(())); assert_eq!(supervisor_called_count, 1); - assert_eq!(count.load(Ordering::SeqCst), 0); + assert_eq!(count.load(Ordering::Acquire), 0); } #[test] @@ -284,7 +284,7 @@ fn restarting_panicking_actor_process() { assert_eq!(res, Poll::Pending); assert_eq!(supervisor_called_count.get(), 1); // The future to wake itself after a restart to ensure it gets run again. - assert_eq!(count.load(Ordering::SeqCst), 1); + assert_eq!(count.load(Ordering::Acquire), 1); // After a restart the actor should continue without issues. let res = actor.as_mut().poll(&mut ctx); @@ -293,7 +293,7 @@ fn restarting_panicking_actor_process() { // Finally after sending it a message it should complete. actor_ref.try_send(()).unwrap(); - assert_eq!(count.load(Ordering::SeqCst), 2); + assert_eq!(count.load(Ordering::Acquire), 2); let res = actor.as_mut().poll(&mut ctx); assert_eq!(res, Poll::Ready(())); assert_eq!(supervisor_called_count.get(), 1); @@ -306,7 +306,7 @@ pub(crate) fn task_wake_counter() -> (task::Waker, Arc) { impl task::Wake for WakeCounter { fn wake(self: Arc) { - _ = self.0.fetch_add(1, Ordering::SeqCst); + _ = self.0.fetch_add(1, Ordering::AcqRel); } } diff --git a/src/test.rs b/src/test.rs index e096793b..f1ed0418 100644 --- a/src/test.rs +++ b/src/test.rs @@ -42,12 +42,12 @@ pub fn set_message_loss(mut percent: u8) { if percent > 100 { percent = 100; } - MSG_LOSS.store(percent, Ordering::SeqCst); + MSG_LOSS.store(percent, Ordering::Release); } /// Returns `true` if the message should be lost. pub(crate) fn should_lose_msg() -> bool { - // Safety: `Relaxed` is fine here as we'll get the update, sending a message + // SAFETY: `Relaxed` is fine here as we'll get the update, sending a message // when we're not supposed to isn't too bad. let loss = MSG_LOSS.load(Ordering::Relaxed); loss != 0 || random_percentage() < loss