From b8d38f67c318aa243104af209d190935644b46ad Mon Sep 17 00:00:00 2001 From: tison Date: Fri, 7 Feb 2025 11:29:58 +0800 Subject: [PATCH] deps: switch between tokio impls with cfg(madsim) (#856) Signed-off-by: tison --- Cargo.toml | 9 --------- foyer-bench/Cargo.toml | 23 ++++++++++++++++++++++- foyer-common/Cargo.toml | 23 ++++++++++++++++++++++- foyer-memory/Cargo.toml | 23 ++++++++++++++++++++++- foyer-storage/Cargo.toml | 23 ++++++++++++++++++++++- foyer/Cargo.toml | 23 ++++++++++++++++++++++- 6 files changed, 110 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2db38c8c..3803060e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,15 +40,6 @@ test-log = { version = "0.2", default-features = false, features = [ "color", ] } thiserror = "2" -tokio = { package = "madsim-tokio", version = "0.2", features = [ - "rt", - "rt-multi-thread", - "sync", - "macros", - "time", - "signal", - "fs", -] } tracing = "0.1" prometheus = "0.13" mixtrics = "0.0.3" diff --git a/foyer-bench/Cargo.toml b/foyer-bench/Cargo.toml index e62d1502..9cc00bac 100644 --- a/foyer-bench/Cargo.toml +++ b/foyer-bench/Cargo.toml @@ -36,13 +36,34 @@ rand = { workspace = true } rand_distr = { workspace = true } serde = { workspace = true } serde_bytes = "0.11.15" -tokio = { workspace = true, features = ["net"] } tracing = { workspace = true } tracing-subscriber = { version = "0.3", features = ["env-filter"] } [target.'cfg(not(target_env = "msvc"))'.dependencies] tikv-jemallocator = { version = "0.6", optional = true } +[target.'cfg(madsim)'.dependencies] +tokio = { package = "madsim-tokio", version = "0.2", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + +[target.'cfg(not(madsim))'.dependencies] +tokio = { package = "tokio", version = "1", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + [features] default = ["jemalloc"] deadlock = ["parking_lot/deadlock_detection", "foyer/deadlock"] diff --git a/foyer-common/Cargo.toml b/foyer-common/Cargo.toml index cadc9693..2094364a 100644 --- a/foyer-common/Cargo.toml +++ b/foyer-common/Cargo.toml @@ -21,13 +21,34 @@ mixtrics = { workspace = true } parking_lot = { workspace = true } pin-project = "1" serde = { workspace = true } -tokio = { workspace = true } [dev-dependencies] futures-util = { workspace = true } mixtrics = { workspace = true, features = ["test-utils"] } rand = { workspace = true } +[target.'cfg(madsim)'.dependencies] +tokio = { package = "madsim-tokio", version = "0.2", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + +[target.'cfg(not(madsim))'.dependencies] +tokio = { package = "tokio", version = "1", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + [features] strict_assertions = [] tracing = ["fastrace/enable"] diff --git a/foyer-memory/Cargo.toml b/foyer-memory/Cargo.toml index b035d596..525f3bf1 100644 --- a/foyer-memory/Cargo.toml +++ b/foyer-memory/Cargo.toml @@ -27,7 +27,6 @@ parking_lot = { workspace = true } pin-project = "1" serde = { workspace = true } thiserror = { workspace = true } -tokio = { workspace = true } tracing = { workspace = true } [dev-dependencies] @@ -38,6 +37,28 @@ rand = { workspace = true, features = ["small_rng"] } rand_distr = { workspace = true } test-log = { workspace = true } +[target.'cfg(madsim)'.dependencies] +tokio = { package = "madsim-tokio", version = "0.2", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + +[target.'cfg(not(madsim))'.dependencies] +tokio = { package = "tokio", version = "1", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + [features] nightly = ["hashbrown/nightly"] deadlock = ["parking_lot/deadlock_detection"] diff --git a/foyer-storage/Cargo.toml b/foyer-storage/Cargo.toml index 56c37762..d67803bb 100644 --- a/foyer-storage/Cargo.toml +++ b/foyer-storage/Cargo.toml @@ -41,7 +41,6 @@ pin-project = "1" rand = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } -tokio = { workspace = true } tracing = { workspace = true } twox-hash = "2" zstd = "0.13" @@ -51,6 +50,28 @@ bytesize = { workspace = true } tempfile = "3" test-log = { workspace = true } +[target.'cfg(madsim)'.dependencies] +tokio = { package = "madsim-tokio", version = "0.2", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + +[target.'cfg(not(madsim))'.dependencies] +tokio = { package = "tokio", version = "1", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + [features] default = [] deadlock = ["parking_lot/deadlock_detection"] diff --git a/foyer/Cargo.toml b/foyer/Cargo.toml index 0f115413..a7b6c599 100644 --- a/foyer/Cargo.toml +++ b/foyer/Cargo.toml @@ -24,13 +24,34 @@ foyer-common = { workspace = true } foyer-memory = { workspace = true } foyer-storage = { workspace = true } mixtrics = { workspace = true } -tokio = { workspace = true } tracing = { workspace = true } [dev-dependencies] tempfile = "3" test-log = { workspace = true } +[target.'cfg(madsim)'.dependencies] +tokio = { package = "madsim-tokio", version = "0.2", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + +[target.'cfg(not(madsim))'.dependencies] +tokio = { package = "tokio", version = "1", features = [ + "rt", + "rt-multi-thread", + "sync", + "macros", + "time", + "signal", + "fs", +] } + [features] default = [] nightly = ["foyer-storage/nightly", "foyer-memory/nightly"]