From 4e45b26e11126b191701b9b2ce5e2346b8d7682f Mon Sep 17 00:00:00 2001 From: Mark Logan Date: Mon, 3 Oct 2022 11:49:24 -0700 Subject: [PATCH] Add FallibleTask::is_finished() --- src/task.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/task.rs b/src/task.rs index 8ecd746..c3c83e1 100644 --- a/src/task.rs +++ b/src/task.rs @@ -513,6 +513,13 @@ impl FallibleTask { pub async fn cancel(self) -> Option { self.task.cancel().await } + + /// Returns `true` if the current task is finished. + /// + /// Note that in a multithreaded environment, this task can change finish immediately after calling this function. + pub fn is_finished(&self) -> bool { + self.task.is_finished() + } } impl Future for FallibleTask {