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

Move CachePadded to separate sub-crate #1069

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ std = [
alloc = ["crossbeam-epoch/alloc", "crossbeam-queue/alloc"]

[dependencies]
crossbeam-cachepadded = { version = "0.0", path = "crossbeam-cachepadded", default-features = false, optional = true }
crossbeam-channel = { version = "0.5.10", path = "crossbeam-channel", default-features = false, optional = true }
crossbeam-deque = { version = "0.8.4", path = "crossbeam-deque", default-features = false, optional = true }
crossbeam-epoch = { version = "0.9.17", path = "crossbeam-epoch", default-features = false, optional = true }
Expand All @@ -52,6 +53,7 @@ workspace = true
resolver = "2"
members = [
".",
"crossbeam-cachepadded",
"crossbeam-channel",
"crossbeam-channel/benchmarks",
"crossbeam-deque",
Expand Down
16 changes: 16 additions & 0 deletions crossbeam-cachepadded/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "crossbeam-cachepadded"
# When publishing a new version:
# - Update CHANGELOG.md
# - Update README.md
# - Create "crossbeam-cachepadded-X.Y.Z" git tag
version = "0.0.0"
edition = "2018"
rust-version = "1.38"
license = "MIT OR Apache-2.0"
repository = "https://github.com/crossbeam-rs/crossbeam"
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-cachepadded"
documentation = "https://docs.rs/crossbeam-cachepadded"
description = "Prevent false sharing by padding and aligning to the length of a cache line"
keywords = ["cache", "padding", "lock-free", "atomic"]
categories = ["concurrency", "no-std"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
//! TODO

#![doc(test(
no_crate_inject,
attr(
deny(warnings, rust_2018_idioms),
allow(dead_code, unused_assignments, unused_variables)
)
))]
#![warn(
missing_docs,
missing_debug_implementations,
rust_2018_idioms,
unreachable_pub
)]
#![no_std]

use core::fmt;
use core::ops::{Deref, DerefMut};

Expand Down Expand Up @@ -34,7 +51,7 @@ use core::ops::{Deref, DerefMut};
/// Alignment and padding:
///
/// ```
/// use crossbeam_utils::CachePadded;
/// use crossbeam_cachepadded::CachePadded;
///
/// let array = [CachePadded::new(1i8), CachePadded::new(2i8)];
/// let addr1 = &*array[0] as *const i8 as usize;
Expand All @@ -50,7 +67,7 @@ use core::ops::{Deref, DerefMut};
/// each other's cache lines:
///
/// ```
/// use crossbeam_utils::CachePadded;
/// use crossbeam_cachepadded::CachePadded;
/// use std::sync::atomic::AtomicUsize;
///
/// struct Queue<T> {
Expand Down Expand Up @@ -156,7 +173,7 @@ impl<T> CachePadded<T> {
/// # Examples
///
/// ```
/// use crossbeam_utils::CachePadded;
/// use crossbeam_cachepadded::CachePadded;
///
/// let padded_value = CachePadded::new(1);
/// ```
Expand All @@ -169,7 +186,7 @@ impl<T> CachePadded<T> {
/// # Examples
///
/// ```
/// use crossbeam_utils::CachePadded;
/// use crossbeam_cachepadded::CachePadded;
///
/// let padded_value = CachePadded::new(7);
/// let value = padded_value.into_inner();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::cell::Cell;
use std::mem;

use crossbeam_utils::CachePadded;
use crossbeam_cachepadded::CachePadded;

#[test]
fn default() {
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ std = []
[dependencies]
cfg-if = "1"

crossbeam-cachepadded = { version = "0.0", path = "../crossbeam-cachepadded", default-features = false }

# Enable the use of loom for concurrency testing.
#
# NOTE: This feature is outside of the normal semver guarantees and minor or
Expand Down
3 changes: 1 addition & 2 deletions crossbeam-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ mod primitive {

pub mod atomic;

mod cache_padded;
pub use crate::cache_padded::CachePadded;
pub use crossbeam_cachepadded::CachePadded;

mod backoff;
pub use crate::backoff::Backoff;
Expand Down
5 changes: 5 additions & 0 deletions tests/subcrates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ fn utils() {
})
.unwrap();
}

#[test]
fn cachepadded() {
crossbeam::utils::CachePadded::new(7);
}