feat(tasks) : add docs (#5274)

This commit is contained in:
DoTheBestToGetTheBest
2023-11-03 04:45:25 -07:00
committed by GitHub
parent ddcd4d600e
commit 9fc0e7637f

View File

@ -18,16 +18,19 @@ pub struct TaskExecutorMetrics {
} }
impl TaskExecutorMetrics { impl TaskExecutorMetrics {
/// Increments the counter for spawned critical tasks.
pub(crate) fn inc_critical_tasks(&self) { pub(crate) fn inc_critical_tasks(&self) {
self.critical_tasks.increment(1); self.critical_tasks.increment(1);
} }
/// Increments the counter for spawned regular tasks.
pub(crate) fn inc_regular_tasks(&self) { pub(crate) fn inc_regular_tasks(&self) {
self.regular_tasks.increment(1); 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); pub struct IncCounterOnDrop(Counter);
impl fmt::Debug for IncCounterOnDrop { impl fmt::Debug for IncCounterOnDrop {
@ -37,13 +40,15 @@ impl fmt::Debug for IncCounterOnDrop {
} }
impl IncCounterOnDrop { impl IncCounterOnDrop {
/// Create a new `IncCounterOnDrop`. /// Creates a new instance of `IncCounterOnDrop` with the given counter.
pub fn new(counter: Counter) -> Self { pub fn new(counter: Counter) -> Self {
IncCounterOnDrop(counter) IncCounterOnDrop(counter)
} }
} }
impl Drop for IncCounterOnDrop { impl Drop for IncCounterOnDrop {
/// Increment the counter when the instance is dropped.
fn drop(&mut self) { fn drop(&mut self) {
self.0.increment(1); self.0.increment(1);
} }