diff --git a/crates/tasks/src/metrics.rs b/crates/tasks/src/metrics.rs index 89edaa245..65163b4b0 100644 --- a/crates/tasks/src/metrics.rs +++ b/crates/tasks/src/metrics.rs @@ -18,16 +18,19 @@ pub struct TaskExecutorMetrics { } impl TaskExecutorMetrics { + /// Increments the counter for spawned critical tasks. + pub(crate) fn inc_critical_tasks(&self) { self.critical_tasks.increment(1); } + /// Increments the counter for spawned regular tasks. pub(crate) fn inc_regular_tasks(&self) { self.regular_tasks.increment(1); } } -/// Helper type for increasing counters even if a task fails. +/// Helper type for increasing counters even if a task fails pub struct IncCounterOnDrop(Counter); impl fmt::Debug for IncCounterOnDrop { @@ -37,13 +40,15 @@ impl fmt::Debug for IncCounterOnDrop { } impl IncCounterOnDrop { - /// Create a new `IncCounterOnDrop`. + /// Creates a new instance of `IncCounterOnDrop` with the given counter. pub fn new(counter: Counter) -> Self { IncCounterOnDrop(counter) } } impl Drop for IncCounterOnDrop { + /// Increment the counter when the instance is dropped. + fn drop(&mut self) { self.0.increment(1); }