diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d15cd6a..4da97d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: env: RUSTFLAGS: -Dwarnings RUST_BACKTRACE: 1 - MSRV: 1.42.0 + MSRV: 1.68.0 jobs: build: diff --git a/Cargo.toml b/Cargo.toml index a43d3b9..3d94aa9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,12 @@ name = "sharded-slab" version = "0.1.7" authors = ["Eliza Weisman "] -edition = "2018" +edition = "2021" documentation = "https://docs.rs/sharded-slab/" homepage = "https://github.com/hawkw/sharded-slab" repository = "https://github.com/hawkw/sharded-slab" readme = "README.md" -rust-version = "1.42.0" +rust-version = "1.68.0" license = "MIT" keywords = ["slab", "allocator", "lock-free", "atomic"] categories = ["memory-management", "data-structures", "concurrency"] @@ -33,7 +33,6 @@ name = "bench" harness = false [dependencies] -lazy_static = "1" [dev-dependencies] proptest = "1" @@ -44,6 +43,7 @@ indexmap = "1" # newer versions lead to "candidate versions found which didn't m [target.'cfg(loom)'.dependencies] loom = { version = "0.5", features = ["checkpoint"], optional = true } +once_cell = "1.0" [target.'cfg(loom)'.dev-dependencies] loom = { version = "0.5", features = ["checkpoint"] } diff --git a/src/sync.rs b/src/sync.rs index 64a31dc..39d5eb3 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -6,9 +6,7 @@ mod inner { pub use loom::sync::atomic::*; pub use std::sync::atomic::Ordering; } - pub(crate) use loom::{ - cell::UnsafeCell, hint, lazy_static, sync::Mutex, thread::yield_now, thread_local, - }; + pub(crate) use loom::{cell::UnsafeCell, hint, sync::Mutex, thread::yield_now, thread_local}; pub(crate) mod alloc { #![allow(dead_code)] @@ -62,8 +60,6 @@ mod inner { #[cfg(not(all(loom, any(feature = "loom", test))))] mod inner { - #![allow(dead_code)] - pub(crate) use lazy_static::lazy_static; pub(crate) use std::{ sync::{atomic, Mutex}, thread::yield_now, @@ -123,18 +119,6 @@ mod inner { pub fn get_ref(&self) -> &T { &self.value } - - /// Get a mutable reference to the value - #[inline(always)] - pub fn get_mut(&mut self) -> &mut T { - &mut self.value - } - - /// Stop tracking the value for leaks - #[inline(always)] - pub fn into_inner(self) -> T { - self.value - } } } } diff --git a/src/tid.rs b/src/tid.rs index f2cb7e0..6d79eba 100644 --- a/src/tid.rs +++ b/src/tid.rs @@ -3,7 +3,7 @@ use crate::{ page, sync::{ atomic::{AtomicUsize, Ordering}, - lazy_static, thread_local, Mutex, + thread_local, Mutex, }, Pack, }; @@ -29,12 +29,17 @@ struct Registry { free: Mutex>, } -lazy_static! { - static ref REGISTRY: Registry = Registry { - next: AtomicUsize::new(0), - free: Mutex::new(VecDeque::new()), - }; -} +// Loom's AtomicUsize and Mutex are not const initializable yet. +#[cfg(not(all(loom, any(test, feature = "loom"))))] +static REGISTRY: Registry = Registry { + next: AtomicUsize::new(0), + free: Mutex::new(VecDeque::new()), +}; +#[cfg(all(loom, any(test, feature = "loom")))] +static REGISTRY: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| Registry { + next: AtomicUsize::new(0), + free: Mutex::new(VecDeque::new()), +}); thread_local! { static REGISTRATION: Registration = Registration::new();