Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(subscriber): fix compilation on targets without 64-bit atomics #282

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions console-subscriber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ parking_lot = ["parking_lot_crate", "tracing-subscriber/parking_lot"]

[dependencies]

crossbeam-utils = "0.8.7"
tokio = { version = "^1.15", features = ["sync", "time", "macros", "tracing"] }
tokio-stream = "0.1"
thread_local = "1.1.3"
Expand Down
11 changes: 6 additions & 5 deletions console-subscriber/src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::{attribute, sync::Mutex, ToProto};
use crossbeam_utils::atomic::AtomicCell;
use hdrhistogram::{
serialization::{Serializer, V2Serializer},
Histogram,
};
use std::cmp;
use std::sync::{
atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering::*},
atomic::{AtomicBool, AtomicUsize, Ordering::*},
Arc,
};
use std::time::{Duration, SystemTime};
Expand Down Expand Up @@ -70,7 +71,7 @@ pub(crate) struct AsyncOpStats {
///
/// This is set every time the async op is polled, in case a future is
/// passed between tasks.
task_id: AtomicU64,
task_id: AtomicCell<u64>,

/// Fields shared with `ResourceStats`.
pub(crate) stats: ResourceStats,
Expand Down Expand Up @@ -265,14 +266,14 @@ impl AsyncOpStats {
parent_id: Option<Id>,
) -> Self {
Self {
task_id: AtomicU64::new(0),
task_id: AtomicCell::new(0),
stats: ResourceStats::new(created_at, inherit_child_attributes, parent_id),
poll_stats: PollStats::default(),
}
}

pub(crate) fn task_id(&self) -> Option<u64> {
let id = self.task_id.load(Acquire);
let id = self.task_id.load();
if id > 0 {
Some(id as u64)
} else {
Expand All @@ -281,7 +282,7 @@ impl AsyncOpStats {
}

pub(crate) fn set_task_id(&self, id: &tracing::span::Id) {
self.task_id.store(id.into_u64(), Release);
self.task_id.store(id.into_u64());
self.make_dirty();
}

Expand Down