Skip to content

Commit 1964fd2

Browse files
authored
feat: bind warn-on-block to debug-assertions (#53)
Rationale: 1. `pin-project` only produces a few generics and introduces a few macros, meaning virtually no compile time or binary size overhead, so having it build inconditionally is not a problem; 2. Using a conditional feature means we need to propagate to the topmost manifest to actually use it; 3. It is reasonable enough to run this whenever we want extra checks, that is when we use `debug-assertions`. So, remove the feature, force the dependency and enable the check for debug-asserted builds.
1 parent d68258d commit 1964fd2

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

concurrency/Cargo.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ spawned-rt = { workspace = true }
1010
tracing = { workspace = true }
1111
futures = "0.3.1"
1212
thiserror = "2.0.12"
13-
pin-project-lite = { version = "0.2", optional = true }
13+
pin-project-lite = "0.2"
1414

1515
[dev-dependencies]
1616
# This tokio imports are only used in tests, we should not use them in the library code.
1717
tokio-stream = { version = "0.1.17" }
1818
tokio = { version = "1", features = ["full"] }
19-
20-
[lib]
21-
path = "./src/lib.rs"
22-
23-
[features]
24-
# Enable this to log warnings when non-blocking GenServers block the runtime for too much time
25-
warn-on-block = ["dep:pin-project-lite"]

concurrency/src/tasks/gen_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<G: GenServer> GenServerHandle<G> {
4141
}
4242
};
4343

44-
#[cfg(feature = "warn-on-block")]
44+
#[cfg(debug_assertions)]
4545
// Optionally warn if the GenServer future blocks for too much time
4646
let inner_future = warn_on_block::WarnOnBlocking::new(inner_future);
4747

@@ -300,7 +300,7 @@ pub trait GenServer: Send + Sized {
300300
}
301301
}
302302

303-
#[cfg(feature = "warn-on-block")]
303+
#[cfg(debug_assertions)]
304304
mod warn_on_block {
305305
use super::*;
306306

0 commit comments

Comments
 (0)