Skip to content

Commit 50d2b85

Browse files
committed
Make loom dependency optional
1 parent d709c89 commit 50d2b85

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

ci/crossbeam-epoch-loom.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export RUSTFLAGS="-D warnings --cfg crossbeam_loom --cfg crossbeam_sanitize"
88
# With MAX_PREEMPTIONS=2 the loom tests (currently) take around 11m.
99
# If we were to run with =3, they would take several times that,
1010
# which is probably too costly for CI.
11-
env LOOM_MAX_PREEMPTIONS=2 cargo test --test loom --release -- --nocapture
11+
env LOOM_MAX_PREEMPTIONS=2 cargo test --test loom --release --features loom -- --nocapture

crossbeam-epoch/Cargo.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ alloc = []
3232
# of crossbeam may make breaking changes to them at any time.
3333
nightly = ["crossbeam-utils/nightly", "const_fn"]
3434

35+
# Enable the use of loom for concurrency testing.
36+
#
37+
# This configuration option is outside of the normal semver guarantees: minor
38+
# versions of crossbeam may make breaking changes to it at any time.
39+
loom = ["loom-crate", "crossbeam-utils/loom"]
40+
3541
[dependencies]
3642
cfg-if = "1"
3743
const_fn = { version = "0.4.4", optional = true }
@@ -42,7 +48,7 @@ memoffset = "0.6"
4248
# This configuration option is outside of the normal semver guarantees: minor
4349
# versions of crossbeam may make breaking changes to it at any time.
4450
[target.'cfg(crossbeam_loom)'.dependencies]
45-
loom = "0.4"
51+
loom-crate = { package = "loom", version = "0.4", optional = true }
4652

4753
[dependencies.crossbeam-utils]
4854
version = "0.8"

crossbeam-epoch/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic))]
6666
#![cfg_attr(feature = "nightly", feature(const_fn))]
6767

68+
#[cfg(crossbeam_loom)]
69+
extern crate loom_crate as loom;
70+
6871
use cfg_if::cfg_if;
6972

7073
#[cfg(crossbeam_loom)]

crossbeam-epoch/tests/loom.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![cfg(crossbeam_loom)]
22

33
use crossbeam_epoch as epoch;
4+
use loom_crate as loom;
45

56
use epoch::*;
67
use epoch::{Atomic, Owned};

crossbeam-utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ lazy_static = { version = "1.4.0", optional = true }
3737
# This configuration option is outside of the normal semver guarantees: minor
3838
# versions of crossbeam may make breaking changes to it at any time.
3939
[target.'cfg(crossbeam_loom)'.dependencies]
40-
loom = "0.4"
40+
loom = { version = "0.4", optional = true }
4141

4242
[build-dependencies]
4343
autocfg = "1.0.0"

0 commit comments

Comments
 (0)