completion: Debug and query for barrier connection

This commit is contained in:
Joonas Koivunen
2024-07-19 16:05:12 +00:00
parent f23ee2ccdb
commit f398ab0264

View File

@@ -8,6 +8,21 @@ pub struct Completion {
_token: TaskTrackerToken,
}
impl std::fmt::Debug for Completion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Completion")
.field("siblings", &self._token.task_tracker().len())
.finish()
}
}
impl Completion {
/// Returns true if this completion is associated with the given barrier.
pub fn blocks(&self, barrier: &Barrier) -> bool {
TaskTracker::ptr_eq(self._token.task_tracker(), &barrier.0)
}
}
/// Barrier will wait until all clones of [`Completion`] have been dropped.
#[derive(Clone)]
pub struct Barrier(TaskTracker);