Adjust create_counter to avoid imposing an AtomicUsize import on users

This commit is contained in:
Michael Vines 2019-02-13 20:04:20 -08:00 committed by Grimes
parent 0f8ff07b51
commit 8790a92f07
15 changed files with 14 additions and 19 deletions

View File

@ -12,7 +12,6 @@ use solana_sdk::pubkey::Pubkey;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::ops::Deref; use std::ops::Deref;
use std::sync::atomic::AtomicUsize;
use std::sync::{Mutex, RwLock}; use std::sync::{Mutex, RwLock};
pub type InstructionAccounts = Vec<Account>; pub type InstructionAccounts = Vec<Account>;

View File

@ -19,7 +19,7 @@ use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing; use solana_sdk::timing;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::Ordering;
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError}; use std::sync::mpsc::{channel, Receiver, RecvTimeoutError};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread::{self, Builder, JoinHandle}; use std::thread::{self, Builder, JoinHandle};

View File

@ -18,7 +18,7 @@ use solana_metrics::{influxdb, submit};
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::duration_as_ms; use solana_sdk::timing::duration_as_ms;
use std::net::UdpSocket; use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{Receiver, RecvTimeoutError}; use std::sync::mpsc::{Receiver, RecvTimeoutError};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle}; use std::thread::{self, Builder, JoinHandle};

View File

@ -41,7 +41,7 @@ use std::cmp::min;
use std::fmt; use std::fmt;
use std::io; use std::io;
use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket}; use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread::{sleep, Builder, JoinHandle}; use std::thread::{sleep, Builder, JoinHandle};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};

View File

@ -5,7 +5,7 @@ use crate::result::Result;
use crate::service::Service; use crate::service::Service;
use crate::streamer::PacketSender; use crate::streamer::PacketSender;
use log::Level; use log::Level;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread::{self, sleep, Builder, JoinHandle}; use std::thread::{self, sleep, Builder, JoinHandle};
use std::time::Duration; use std::time::Duration;

View File

@ -20,10 +20,10 @@ macro_rules! create_counter {
($name:expr, $lograte:expr) => { ($name:expr, $lograte:expr) => {
Counter { Counter {
name: $name, name: $name,
counts: AtomicUsize::new(0), counts: std::sync::atomic::AtomicUsize::new(0),
times: AtomicUsize::new(0), times: std::sync::atomic::AtomicUsize::new(0),
lastlog: AtomicUsize::new(0), lastlog: std::sync::atomic::AtomicUsize::new(0),
lograte: AtomicUsize::new($lograte), lograte: std::sync::atomic::AtomicUsize::new($lograte),
point: None, point: None,
} }
}; };
@ -116,7 +116,7 @@ mod tests {
use crate::counter::{Counter, DEFAULT_LOG_RATE}; use crate::counter::{Counter, DEFAULT_LOG_RATE};
use log::Level; use log::Level;
use std::env; use std::env;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::Ordering;
use std::sync::{Once, RwLock, ONCE_INIT}; use std::sync::{Once, RwLock, ONCE_INIT};
fn get_env_lock() -> &'static RwLock<()> { fn get_env_lock() -> &'static RwLock<()> {

View File

@ -11,7 +11,6 @@ use log::Level;
use solana_metrics::{influxdb, submit}; use solana_metrics::{influxdb, submit};
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use std::borrow::Borrow; use std::borrow::Borrow;
use std::sync::atomic::AtomicUsize;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
pub const MAX_REPAIR_LENGTH: usize = 128; pub const MAX_REPAIR_LENGTH: usize = 128;

View File

@ -22,7 +22,7 @@ use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::timing::{duration_as_ms, timestamp}; use solana_sdk::timing::{duration_as_ms, timestamp};
use std::net::UdpSocket; use std::net::UdpSocket;
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender, SyncSender}; use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender, SyncSender};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread::{sleep, spawn, Result}; use std::thread::{sleep, spawn, Result};

View File

@ -12,7 +12,6 @@ use std::fmt;
use std::io; use std::io;
use std::mem::size_of; use std::mem::size_of;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket};
use std::sync::atomic::AtomicUsize;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
pub type SharedPackets = Arc<RwLock<Packets>>; pub type SharedPackets = Arc<RwLock<Packets>>;

View File

@ -16,7 +16,7 @@ use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::duration_as_ms; use solana_sdk::timing::duration_as_ms;
use solana_sdk::vote_transaction::VoteTransaction; use solana_sdk::vote_transaction::VoteTransaction;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Receiver, SyncSender}; use std::sync::mpsc::{channel, Receiver, SyncSender};
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
#[cfg(test)] #[cfg(test)]

View File

@ -16,7 +16,7 @@ use core::cmp;
use log::Level; use log::Level;
use solana_metrics::{influxdb, submit}; use solana_metrics::{influxdb, submit};
use std::net::UdpSocket; use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::sync::atomic::AtomicBool;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::sync::mpsc::RecvTimeoutError; use std::sync::mpsc::RecvTimeoutError;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};

View File

@ -15,7 +15,6 @@ use solana_sdk::signature::Signature;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use std::io::Cursor; use std::io::Cursor;
use std::mem::size_of; use std::mem::size_of;
use std::sync::atomic::AtomicUsize;
pub const TX_OFFSET: usize = 0; pub const TX_OFFSET: usize = 0;

View File

@ -16,7 +16,6 @@ use log::Level;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_metrics::{influxdb, submit}; use solana_metrics::{influxdb, submit};
use solana_sdk::timing; use solana_sdk::timing;
use std::sync::atomic::AtomicUsize;
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender}; use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread::{self, spawn, JoinHandle}; use std::thread::{self, spawn, JoinHandle};

View File

@ -11,7 +11,7 @@ use crate::streamer::{self, PacketReceiver};
use log::Level; use log::Level;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use std::net::{SocketAddr, UdpSocket}; use std::net::{SocketAddr, UdpSocket};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle}; use std::thread::{self, Builder, JoinHandle};

View File

@ -14,7 +14,7 @@ use solana_metrics::{influxdb, submit};
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::duration_as_ms; use solana_sdk::timing::duration_as_ms;
use std::net::UdpSocket; use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::RecvTimeoutError; use std::sync::mpsc::RecvTimeoutError;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle}; use std::thread::{self, Builder, JoinHandle};