Skip to content

Commit

Permalink
impl: switch to relaxed memory ordering
Browse files Browse the repository at this point in the history
Relaxed is sufficient here as printed merely serves as an atomic
signal in a multithreaded context, providing atomicity but not
synchronization.

PR #82
  • Loading branch information
wang384670111 committed Jan 10, 2024
1 parent e5f7a6c commit 6dc655f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ impl BufferWriter {
}
let mut stream = self.stream.wrap(self.stream.get_ref().lock());
if let Some(ref sep) = self.separator {
if self.printed.load(Ordering::SeqCst) {
if self.printed.load(Ordering::Relaxed) {
stream.write_all(sep)?;
stream.write_all(b"\n")?;
}
Expand All @@ -1163,7 +1163,7 @@ impl BufferWriter {
b.print(&mut *console, &mut stream)?;
}
}
self.printed.store(true, Ordering::SeqCst);
self.printed.store(true, Ordering::Relaxed);
Ok(())
}
}
Expand Down

0 comments on commit 6dc655f

Please sign in to comment.