Skip to content

Commit

Permalink
metrics: use mocked AtomicU64 in IO metrics driver (#4649)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn authored May 2, 2022
1 parent fa665b9 commit dc54aec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ jobs:
- powerpc64-unknown-linux-gnu
- mips-unknown-linux-gnu
- arm-linux-androideabi
- mipsel-unknown-linux-musl
steps:
- uses: actions/checkout@v2
- name: Install Rust ${{ env.rust_stable }}
Expand All @@ -241,7 +242,14 @@ jobs:
with:
use-cross: true
command: check
args: --workspace --target ${{ matrix.target }}
args: --workspace --all-features --target ${{ matrix.target }}
- uses: actions-rs/cargo@v1
with:
use-cross: true
command: check
args: --workspace --all-features --target ${{ matrix.target }}
env:
RUSTFLAGS: --cfg tokio_unstable -Dwarnings

features:
name: features
Expand Down
4 changes: 4 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build.env]
passthrough = [
"RUSTFLAGS",
]
8 changes: 8 additions & 0 deletions tokio/src/loom/std/atomic_u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,12 @@ cfg_not_has_atomic_u64! {
self.compare_exchange(current, new, success, failure)
}
}

impl Default for AtomicU64 {
fn default() -> AtomicU64 {
Self {
inner: Mutex::new(0),
}
}
}
}
2 changes: 1 addition & 1 deletion tokio/src/runtime/metrics/io.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg_attr(not(feature = "net"), allow(dead_code))]

use std::sync::atomic::{AtomicU64, Ordering::Relaxed};
use crate::loom::sync::atomic::{AtomicU64, Ordering::Relaxed};

#[derive(Default)]
pub(crate) struct IoDriverMetrics {
Expand Down

0 comments on commit dc54aec

Please sign in to comment.