Skip to content

Commit 5a6965b

Browse files
committed
Change orderings of Debug for the Atomic types to Relaxed.
This reduces synchronization between threads when debugging the atomic types. Reducing the synchronization means that executions with and without the debug calls will be more consistent, making it easier to debug.
1 parent 2a768f1 commit 5a6965b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/sync/atomic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,7 @@ macro_rules! atomic_int {
15171517
#[$stable_debug]
15181518
impl fmt::Debug for $atomic_type {
15191519
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1520-
fmt::Debug::fmt(&self.load(Ordering::SeqCst), f)
1520+
fmt::Debug::fmt(&self.load(Ordering::Relaxed), f)
15211521
}
15221522
}
15231523

@@ -2996,15 +2996,15 @@ pub fn compiler_fence(order: Ordering) {
29962996
#[stable(feature = "atomic_debug", since = "1.3.0")]
29972997
impl fmt::Debug for AtomicBool {
29982998
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2999-
fmt::Debug::fmt(&self.load(Ordering::SeqCst), f)
2999+
fmt::Debug::fmt(&self.load(Ordering::Relaxed), f)
30003000
}
30013001
}
30023002

30033003
#[cfg(target_has_atomic_load_store = "ptr")]
30043004
#[stable(feature = "atomic_debug", since = "1.3.0")]
30053005
impl<T> fmt::Debug for AtomicPtr<T> {
30063006
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3007-
fmt::Debug::fmt(&self.load(Ordering::SeqCst), f)
3007+
fmt::Debug::fmt(&self.load(Ordering::Relaxed), f)
30083008
}
30093009
}
30103010

0 commit comments

Comments
 (0)