This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 8b9204cfeb Mutable Join Unwind (#16883)
8b9204cfeb is described below

commit 8b9204cfebd83f36f0c3e4b62d23712b469a9d57
Author: Berkay Şahin <124376117+berkaysynn...@users.noreply.github.com>
AuthorDate: Fri Jul 25 22:28:48 2025 +0300

    Mutable Join Unwind (#16883)
    
    * Update common.rs
    
    * Update common.rs
---
 datafusion/common-runtime/src/common.rs | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/datafusion/common-runtime/src/common.rs 
b/datafusion/common-runtime/src/common.rs
index e7aba1d455..cebd6e04cd 100644
--- a/datafusion/common-runtime/src/common.rs
+++ b/datafusion/common-runtime/src/common.rs
@@ -68,15 +68,28 @@ impl<R: 'static> SpawnedTask<R> {
     }
 
     /// Joins the task and unwinds the panic if it happens.
-    pub async fn join_unwind(self) -> Result<R, JoinError> {
+    pub async fn join_unwind(mut self) -> Result<R, JoinError> {
+        self.join_unwind_mut().await
+    }
+
+    /// Joins the task using a mutable reference and unwinds the panic if it 
happens.
+    ///
+    /// This method is similar to [`join_unwind`](Self::join_unwind), but 
takes a mutable
+    /// reference instead of consuming `self`. This allows the `SpawnedTask` 
to remain
+    /// usable after the call.
+    ///
+    /// If called multiple times on the same task:
+    /// - If the task is still running, it will continue waiting for completion
+    /// - If the task has already completed successfully, subsequent calls will
+    ///   continue to return the same `JoinError` indicating the task is 
finished
+    /// - If the task panicked, the first call will resume the panic, and the
+    ///   program will not reach subsequent calls
+    pub async fn join_unwind_mut(&mut self) -> Result<R, JoinError> {
         self.await.map_err(|e| {
             // `JoinError` can be caused either by panic or cancellation. We 
have to handle panics:
             if e.is_panic() {
                 std::panic::resume_unwind(e.into_panic());
             } else {
-                // Cancellation may be caused by two reasons:
-                // 1. Abort is called, but since we consumed `self`, it's not 
our case (`JoinHandle` not accessible outside).
-                // 2. The runtime is shutting down.
                 log::warn!("SpawnedTask was polled during shutdown");
                 e
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org
For additional commands, e-mail: commits-h...@datafusion.apache.org

Reply via email to