Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
MSRV: 1.42.0
MSRV: 1.68.0

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
name = "sharded-slab"
version = "0.1.7"
authors = ["Eliza Weisman <eliza@buoyant.io>"]
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"]
Expand All @@ -33,7 +33,6 @@ name = "bench"
harness = false

[dependencies]
lazy_static = "1"

[dev-dependencies]
proptest = "1"
Expand All @@ -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"] }
Expand Down
18 changes: 1 addition & 17 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
}
}
}
19 changes: 12 additions & 7 deletions src/tid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
page,
sync::{
atomic::{AtomicUsize, Ordering},
lazy_static, thread_local, Mutex,
thread_local, Mutex,
},
Pack,
};
Expand All @@ -29,12 +29,17 @@ struct Registry {
free: Mutex<VecDeque<usize>>,
}

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<Registry> = once_cell::sync::Lazy::new(|| Registry {
next: AtomicUsize::new(0),
free: Mutex::new(VecDeque::new()),
});

thread_local! {
static REGISTRATION: Registration = Registration::new();
Expand Down