Skip to content

Commit b8d38f6

Browse files
authored
deps: switch between tokio impls with cfg(madsim) (#856)
Signed-off-by: tison <wander4096@gmail.com>
1 parent ca3293f commit b8d38f6

File tree

6 files changed

+110
-14
lines changed

6 files changed

+110
-14
lines changed

Cargo.toml

-9
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ test-log = { version = "0.2", default-features = false, features = [
4040
"color",
4141
] }
4242
thiserror = "2"
43-
tokio = { package = "madsim-tokio", version = "0.2", features = [
44-
"rt",
45-
"rt-multi-thread",
46-
"sync",
47-
"macros",
48-
"time",
49-
"signal",
50-
"fs",
51-
] }
5243
tracing = "0.1"
5344
prometheus = "0.13"
5445
mixtrics = "0.0.3"

foyer-bench/Cargo.toml

+22-1
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,34 @@ rand = { workspace = true }
3636
rand_distr = { workspace = true }
3737
serde = { workspace = true }
3838
serde_bytes = "0.11.15"
39-
tokio = { workspace = true, features = ["net"] }
4039
tracing = { workspace = true }
4140
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
4241

4342
[target.'cfg(not(target_env = "msvc"))'.dependencies]
4443
tikv-jemallocator = { version = "0.6", optional = true }
4544

45+
[target.'cfg(madsim)'.dependencies]
46+
tokio = { package = "madsim-tokio", version = "0.2", features = [
47+
"rt",
48+
"rt-multi-thread",
49+
"sync",
50+
"macros",
51+
"time",
52+
"signal",
53+
"fs",
54+
] }
55+
56+
[target.'cfg(not(madsim))'.dependencies]
57+
tokio = { package = "tokio", version = "1", features = [
58+
"rt",
59+
"rt-multi-thread",
60+
"sync",
61+
"macros",
62+
"time",
63+
"signal",
64+
"fs",
65+
] }
66+
4667
[features]
4768
default = ["jemalloc"]
4869
deadlock = ["parking_lot/deadlock_detection", "foyer/deadlock"]

foyer-common/Cargo.toml

+22-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,34 @@ mixtrics = { workspace = true }
2121
parking_lot = { workspace = true }
2222
pin-project = "1"
2323
serde = { workspace = true }
24-
tokio = { workspace = true }
2524

2625
[dev-dependencies]
2726
futures-util = { workspace = true }
2827
mixtrics = { workspace = true, features = ["test-utils"] }
2928
rand = { workspace = true }
3029

30+
[target.'cfg(madsim)'.dependencies]
31+
tokio = { package = "madsim-tokio", version = "0.2", features = [
32+
"rt",
33+
"rt-multi-thread",
34+
"sync",
35+
"macros",
36+
"time",
37+
"signal",
38+
"fs",
39+
] }
40+
41+
[target.'cfg(not(madsim))'.dependencies]
42+
tokio = { package = "tokio", version = "1", features = [
43+
"rt",
44+
"rt-multi-thread",
45+
"sync",
46+
"macros",
47+
"time",
48+
"signal",
49+
"fs",
50+
] }
51+
3152
[features]
3253
strict_assertions = []
3354
tracing = ["fastrace/enable"]

foyer-memory/Cargo.toml

+22-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ parking_lot = { workspace = true }
2727
pin-project = "1"
2828
serde = { workspace = true }
2929
thiserror = { workspace = true }
30-
tokio = { workspace = true }
3130
tracing = { workspace = true }
3231

3332
[dev-dependencies]
@@ -38,6 +37,28 @@ rand = { workspace = true, features = ["small_rng"] }
3837
rand_distr = { workspace = true }
3938
test-log = { workspace = true }
4039

40+
[target.'cfg(madsim)'.dependencies]
41+
tokio = { package = "madsim-tokio", version = "0.2", features = [
42+
"rt",
43+
"rt-multi-thread",
44+
"sync",
45+
"macros",
46+
"time",
47+
"signal",
48+
"fs",
49+
] }
50+
51+
[target.'cfg(not(madsim))'.dependencies]
52+
tokio = { package = "tokio", version = "1", features = [
53+
"rt",
54+
"rt-multi-thread",
55+
"sync",
56+
"macros",
57+
"time",
58+
"signal",
59+
"fs",
60+
] }
61+
4162
[features]
4263
nightly = ["hashbrown/nightly"]
4364
deadlock = ["parking_lot/deadlock_detection"]

foyer-storage/Cargo.toml

+22-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pin-project = "1"
4141
rand = { workspace = true }
4242
serde = { workspace = true }
4343
thiserror = { workspace = true }
44-
tokio = { workspace = true }
4544
tracing = { workspace = true }
4645
twox-hash = "2"
4746
zstd = "0.13"
@@ -51,6 +50,28 @@ bytesize = { workspace = true }
5150
tempfile = "3"
5251
test-log = { workspace = true }
5352

53+
[target.'cfg(madsim)'.dependencies]
54+
tokio = { package = "madsim-tokio", version = "0.2", features = [
55+
"rt",
56+
"rt-multi-thread",
57+
"sync",
58+
"macros",
59+
"time",
60+
"signal",
61+
"fs",
62+
] }
63+
64+
[target.'cfg(not(madsim))'.dependencies]
65+
tokio = { package = "tokio", version = "1", features = [
66+
"rt",
67+
"rt-multi-thread",
68+
"sync",
69+
"macros",
70+
"time",
71+
"signal",
72+
"fs",
73+
] }
74+
5475
[features]
5576
default = []
5677
deadlock = ["parking_lot/deadlock_detection"]

foyer/Cargo.toml

+22-1
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,34 @@ foyer-common = { workspace = true }
2424
foyer-memory = { workspace = true }
2525
foyer-storage = { workspace = true }
2626
mixtrics = { workspace = true }
27-
tokio = { workspace = true }
2827
tracing = { workspace = true }
2928

3029
[dev-dependencies]
3130
tempfile = "3"
3231
test-log = { workspace = true }
3332

33+
[target.'cfg(madsim)'.dependencies]
34+
tokio = { package = "madsim-tokio", version = "0.2", features = [
35+
"rt",
36+
"rt-multi-thread",
37+
"sync",
38+
"macros",
39+
"time",
40+
"signal",
41+
"fs",
42+
] }
43+
44+
[target.'cfg(not(madsim))'.dependencies]
45+
tokio = { package = "tokio", version = "1", features = [
46+
"rt",
47+
"rt-multi-thread",
48+
"sync",
49+
"macros",
50+
"time",
51+
"signal",
52+
"fs",
53+
] }
54+
3455
[features]
3556
default = []
3657
nightly = ["foyer-storage/nightly", "foyer-memory/nightly"]

0 commit comments

Comments
 (0)