Skip to content

Commit

Permalink
Merge pull request dbus2#1009 from zeenix/relax-serial-fetch
Browse files Browse the repository at this point in the history
⚡️ zb: Use relaxed load order for serial number fetch & add
  • Loading branch information
zeenix authored Sep 19, 2024
2 parents 0f25727 + b98d838 commit 1f624f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zbus/src/message/header.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
num::NonZeroU32,
sync::atomic::{AtomicU32, Ordering::SeqCst},
sync::atomic::{AtomicU32, Ordering::Relaxed},
};

use enumflags2::{bitflags, BitFlags};
Expand Down Expand Up @@ -131,9 +131,9 @@ assert_impl_all!(PrimaryHeader: Send, Sync, Unpin);
impl PrimaryHeader {
/// Create a new `PrimaryHeader` instance.
pub fn new(msg_type: Type, body_len: u32) -> Self {
let mut serial_num = SERIAL_NUM.fetch_add(1, SeqCst);
let mut serial_num = SERIAL_NUM.fetch_add(1, Relaxed);
if serial_num == 0 {
serial_num = SERIAL_NUM.fetch_add(1, SeqCst);
serial_num = SERIAL_NUM.fetch_add(1, Relaxed);
}

Self {
Expand Down

0 comments on commit 1f624f9

Please sign in to comment.