mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-29 17:51:35 +00:00
Drop atomic
dependency (#2643)
Replace `atomic::Atomic<u64>` by `std::sync::atomic:AtomicU64`. The original motivation of using `atomic::Atomic<u64>` instead of `std`'s version in #1670 was the following: > I used the atomic crate and an Atomic<u64> because the AtomicU64 type > isn't available on all architectures. The atomic crate automatically > falls back to using a Mutex on platforms that don't support AtomicU64. This argumentation is moot because the crate directly depends on `libp2p-core` which also uses `AtomicU64`.
This commit is contained in:
@ -26,7 +26,6 @@ use crate::{
|
||||
Multiaddr,
|
||||
};
|
||||
|
||||
use atomic::Atomic;
|
||||
use futures::{
|
||||
io::{IoSlice, IoSliceMut},
|
||||
prelude::*,
|
||||
@ -36,7 +35,10 @@ use std::{
|
||||
convert::TryFrom as _,
|
||||
io,
|
||||
pin::Pin,
|
||||
sync::{atomic::Ordering, Arc},
|
||||
sync::{
|
||||
atomic::{AtomicU64, Ordering},
|
||||
Arc,
|
||||
},
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
@ -52,8 +54,8 @@ impl<TInner> BandwidthLogging<TInner> {
|
||||
/// Creates a new [`BandwidthLogging`] around the transport.
|
||||
pub fn new(inner: TInner) -> (Self, Arc<BandwidthSinks>) {
|
||||
let sink = Arc::new(BandwidthSinks {
|
||||
inbound: Atomic::new(0),
|
||||
outbound: Atomic::new(0),
|
||||
inbound: AtomicU64::new(0),
|
||||
outbound: AtomicU64::new(0),
|
||||
});
|
||||
|
||||
let trans = BandwidthLogging {
|
||||
@ -165,8 +167,8 @@ impl<TInner: TryFuture> Future for BandwidthFuture<TInner> {
|
||||
|
||||
/// Allows obtaining the average bandwidth of the connections created from a [`BandwidthLogging`].
|
||||
pub struct BandwidthSinks {
|
||||
inbound: Atomic<u64>,
|
||||
outbound: Atomic<u64>,
|
||||
inbound: AtomicU64,
|
||||
outbound: AtomicU64,
|
||||
}
|
||||
|
||||
impl BandwidthSinks {
|
||||
|
Reference in New Issue
Block a user