mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(tasks) : add docs (#5274)
This commit is contained in:
committed by
GitHub
parent
ddcd4d600e
commit
9fc0e7637f
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user