From f398ab0264bb6d6d0e1e556e81120e0cdf2d904b Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Fri, 19 Jul 2024 16:05:12 +0000 Subject: [PATCH] completion: Debug and query for barrier connection --- libs/utils/src/completion.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libs/utils/src/completion.rs b/libs/utils/src/completion.rs index 75eedd574d..749f454fea 100644 --- a/libs/utils/src/completion.rs +++ b/libs/utils/src/completion.rs @@ -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);