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

Remove ATOMIC_USIZE_INIT #310

Merged
merged 1 commit into from Jan 28, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions crossbeam-epoch/src/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use core::marker::PhantomData;
use core::mem;
use core::ops::{Deref, DerefMut};
use core::ptr;
use core::sync::atomic::Ordering;
use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
use core::sync::atomic::{AtomicUsize, Ordering};

use crossbeam_utils::atomic::AtomicConsume;
use guard::Guard;
Expand Down Expand Up @@ -154,7 +153,7 @@ impl<T> Atomic<T> {
#[cfg(not(feature = "nightly"))]
pub fn null() -> Atomic<T> {
Self {
data: ATOMIC_USIZE_INIT,
data: AtomicUsize::new(0),
_marker: PhantomData,
}
}
Expand All @@ -171,7 +170,7 @@ impl<T> Atomic<T> {
#[cfg(feature = "nightly")]
pub const fn null() -> Atomic<T> {
Self {
data: ATOMIC_USIZE_INIT,
data: AtomicUsize::new(0),
_marker: PhantomData,
}
}
Expand Down
17 changes: 8 additions & 9 deletions crossbeam-epoch/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ impl fmt::Debug for LocalHandle {
#[cfg(test)]
mod tests {
use std::mem;
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
use std::sync::atomic::{AtomicUsize, Ordering};

use crossbeam_utils::thread;

Expand Down Expand Up @@ -196,7 +195,7 @@ mod tests {
#[test]
fn incremental() {
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

let collector = Collector::new();
let handle = collector.register();
Expand Down Expand Up @@ -229,7 +228,7 @@ mod tests {
#[test]
fn buffering() {
const COUNT: usize = 10;
static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

let collector = Collector::new();
let handle = collector.register();
Expand Down Expand Up @@ -262,7 +261,7 @@ mod tests {
#[test]
fn count_drops() {
const COUNT: usize = 100_000;
static DROPS: AtomicUsize = ATOMIC_USIZE_INIT;
static DROPS: AtomicUsize = AtomicUsize::new(0);

struct Elem(i32);

Expand Down Expand Up @@ -295,7 +294,7 @@ mod tests {
#[test]
fn count_destroy() {
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

let collector = Collector::new();
let handle = collector.register();
Expand Down Expand Up @@ -323,7 +322,7 @@ mod tests {
#[test]
fn drop_array() {
const COUNT: usize = 700;
static DROPS: AtomicUsize = ATOMIC_USIZE_INIT;
static DROPS: AtomicUsize = AtomicUsize::new(0);

struct Elem(i32);

Expand Down Expand Up @@ -361,7 +360,7 @@ mod tests {
#[test]
fn destroy_array() {
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = ATOMIC_USIZE_INIT;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

let collector = Collector::new();
let handle = collector.register();
Expand Down Expand Up @@ -396,7 +395,7 @@ mod tests {
fn stress() {
const THREADS: usize = 8;
const COUNT: usize = 100_000;
static DROPS: AtomicUsize = ATOMIC_USIZE_INIT;
static DROPS: AtomicUsize = AtomicUsize::new(0);

struct Elem(i32);

Expand Down
7 changes: 3 additions & 4 deletions crossbeam-epoch/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,13 @@ impl IsElement<Local> for Local {

#[cfg(test)]
mod tests {
use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
use std::sync::atomic::{AtomicUsize, Ordering};

use super::*;

#[test]
fn check_defer() {
static FLAG: AtomicUsize = ATOMIC_USIZE_INIT;
static FLAG: AtomicUsize = AtomicUsize::new(0);
fn set() {
FLAG.store(42, Ordering::Relaxed);
}
Expand All @@ -529,7 +528,7 @@ mod tests {

#[test]
fn check_bag() {
static FLAG: AtomicUsize = ATOMIC_USIZE_INIT;
static FLAG: AtomicUsize = AtomicUsize::new(0);
fn incr() {
FLAG.fetch_add(1, Ordering::Relaxed);
}
Expand Down
6 changes: 3 additions & 3 deletions crossbeam-skiplist/tests/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate crossbeam_epoch as epoch;
extern crate crossbeam_skiplist as skiplist;

use std::ops::Bound;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use std::sync::atomic::{AtomicUsize, Ordering};

use skiplist::SkipList;

Expand Down Expand Up @@ -770,8 +770,8 @@ fn clear() {

#[test]
fn drops() {
static KEYS: AtomicUsize = ATOMIC_USIZE_INIT;
static VALUES: AtomicUsize = ATOMIC_USIZE_INIT;
static KEYS: AtomicUsize = AtomicUsize::new(0);
static VALUES: AtomicUsize = AtomicUsize::new(0);

let collector = epoch::Collector::new();
let handle = collector.register();
Expand Down