diff options
author | Joel Galenson <jgalenson@google.com> | 2021-09-30 08:55:02 -0700 |
---|---|---|
committer | Joel Galenson <jgalenson@google.com> | 2021-09-30 08:55:40 -0700 |
commit | 5fe87985ba723ee4d9532495587d7114e4b6e143 (patch) | |
tree | 71a18fec0599d209bd7c1b95140dc75566fa3788 /src/runtime/handle.rs | |
parent | d61267ffdfea9ed9be38e805f8e3ff78e384005f (diff) | |
download | tokio-5fe87985ba723ee4d9532495587d7114e4b6e143.tar.gz |
Upgrade rust/crates/tokio to 1.12.0
Test: make
Change-Id: I4b0bd405c0b615f886e5a6606e0bf7c0ac7c6699
Diffstat (limited to 'src/runtime/handle.rs')
-rw-r--r-- | src/runtime/handle.rs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/runtime/handle.rs b/src/runtime/handle.rs index ddc170a..bad6a00 100644 --- a/src/runtime/handle.rs +++ b/src/runtime/handle.rs @@ -111,6 +111,14 @@ impl Handle { context::current().ok_or(TryCurrentError(())) } + cfg_stats! { + /// Returns a view that lets you get information about how the runtime + /// is performing. + pub fn stats(&self) -> &crate::runtime::stats::RuntimeStats { + self.spawner.stats() + } + } + /// Spawn a future onto the Tokio runtime. /// /// This spawns the given future onto the runtime's executor, usually a @@ -192,20 +200,20 @@ impl Handle { let location = std::panic::Location::caller(); #[cfg(tokio_track_caller)] let span = tracing::trace_span!( - target: "tokio::task", - "task", + target: "tokio::task::blocking", + "runtime.spawn", kind = %"blocking", - function = %std::any::type_name::<F>(), task.name = %name.unwrap_or_default(), + "fn" = %std::any::type_name::<F>(), spawn.location = %format_args!("{}:{}:{}", location.file(), location.line(), location.column()), ); #[cfg(not(tokio_track_caller))] let span = tracing::trace_span!( - target: "tokio::task", - "task", + target: "tokio::task::blocking", + "runtime.spawn", kind = %"blocking", task.name = %name.unwrap_or_default(), - function = %std::any::type_name::<F>(), + "fn" = %std::any::type_name::<F>(), ); fut.instrument(span) }; @@ -288,7 +296,11 @@ impl Handle { /// [`tokio::fs`]: crate::fs /// [`tokio::net`]: crate::net /// [`tokio::time`]: crate::time + #[cfg_attr(tokio_track_caller, track_caller)] pub fn block_on<F: Future>(&self, future: F) -> F::Output { + #[cfg(all(tokio_unstable, feature = "tracing"))] + let future = crate::util::trace::task(future, "block_on", None); + // Enter the **runtime** context. This configures spawning, the current I/O driver, ... let _rt_enter = self.enter(); |