diff --git a/Cargo.lock b/Cargo.lock index 13b3249..b9eb9ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1197,7 +1197,7 @@ dependencies = [ [[package]] name = "spawned-concurrency" -version = "0.4.0" +version = "0.4.1" dependencies = [ "futures", "pin-project-lite", @@ -1210,7 +1210,7 @@ dependencies = [ [[package]] name = "spawned-rt" -version = "0.4.0" +version = "0.4.1" dependencies = [ "crossbeam", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 802efaf..2b55e5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,12 +16,12 @@ members = [ ] [workspace.dependencies] -spawned-rt = { path = "rt", version = "0.4.0" } -spawned-concurrency = { path = "concurrency", version = "0.4.0" } +spawned-rt = { path = "rt", version = "0.4.1" } +spawned-concurrency = { path = "concurrency", version = "0.4.1" } tracing = { version = "0.1.41", features = ["log"] } tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } [workspace.package] -version = "0.4.0" +version = "0.4.1" license = "MIT" edition = "2021" diff --git a/concurrency/src/tasks/gen_server.rs b/concurrency/src/tasks/gen_server.rs index 7b2fb15..064d42a 100644 --- a/concurrency/src/tasks/gen_server.rs +++ b/concurrency/src/tasks/gen_server.rs @@ -328,12 +328,13 @@ mod warn_on_block { cx: &mut std::task::Context<'_>, ) -> std::task::Poll { let type_id = std::any::type_name::(); + let task_id = rt::task_id(); let this = self.project(); let now = Instant::now(); let res = this.inner.poll(cx); let elapsed = now.elapsed(); if elapsed > Duration::from_millis(10) { - warn!(future = ?type_id, elapsed = ?elapsed, "Blocking operation detected"); + warn!(task = ?task_id, future = ?type_id, elapsed = ?elapsed, "Blocking operation detected"); } res } diff --git a/examples/busy_genserver_warning/main.rs b/examples/busy_genserver_warning/main.rs index e799996..2d6d6ef 100644 --- a/examples/busy_genserver_warning/main.rs +++ b/examples/busy_genserver_warning/main.rs @@ -44,7 +44,7 @@ impl GenServer for BusyWorker { _: Self::CastMsg, handle: &GenServerHandle, ) -> CastResponse { - info!("sleeping"); + info!(taskid = ?rt::task_id(), "sleeping"); thread::sleep(Duration::from_millis(542)); handle.clone().cast(()).await.unwrap(); // This sleep is needed to yield control to the runtime. diff --git a/rt/src/tasks/mod.rs b/rt/src/tasks/mod.rs index 5291f69..09d3294 100644 --- a/rt/src/tasks/mod.rs +++ b/rt/src/tasks/mod.rs @@ -18,7 +18,7 @@ pub use crate::tasks::tokio::oneshot; pub use crate::tasks::tokio::sleep; pub use crate::tasks::tokio::timeout; pub use crate::tasks::tokio::CancellationToken; -pub use crate::tasks::tokio::{spawn, spawn_blocking, JoinHandle, Runtime}; +pub use crate::tasks::tokio::{spawn, spawn_blocking, task_id, JoinHandle, Runtime}; pub use crate::tasks::tokio::{BroadcastStream, ReceiverStream}; use std::future::Future; diff --git a/rt/src/tasks/tokio/mod.rs b/rt/src/tasks/tokio/mod.rs index eac39e0..1bd2bf5 100644 --- a/rt/src/tasks/tokio/mod.rs +++ b/rt/src/tasks/tokio/mod.rs @@ -4,7 +4,7 @@ pub mod oneshot; pub use tokio::{ runtime::Runtime, - task::{spawn, spawn_blocking, JoinHandle}, + task::{id as task_id, spawn, spawn_blocking, JoinHandle}, time::{sleep, timeout}, }; pub use tokio_stream::wrappers::{BroadcastStream, UnboundedReceiverStream as ReceiverStream};