westonpace commented on code in PR #14257:
URL: https://github.com/apache/arrow/pull/14257#discussion_r989222492


##########
cpp/src/arrow/util/async_util.cc:
##########
@@ -190,22 +244,17 @@ class AsyncTaskSchedulerImpl : public AsyncTaskScheduler {
     struct Finalizer {
       void operator()(const Status& st) {
         std::unique_lock<std::mutex> lk(self->mutex_);
-        FnOnce<Status()> finish_callback;
+        FnOnce<Status(Status)> finish_callback =
+            std::move((*child_itr)->finish_callback_);
+        self->sub_schedulers_.erase(child_itr);
+        lk.unlock();
+        Status finish_st = std::move(finish_callback)(st);
+        lk.lock();
+        self->running_tasks_--;
         if (!st.ok()) {
-          self->running_tasks_--;
           self->AbortUnlocked(st, std::move(lk));
           return;
-        } else {
-          // We only eagerly erase the sub-scheduler on a successful 
completion.  This is
-          // because, if the sub-scheduler aborted, then the caller of 
MakeSubScheduler
-          // might still be planning to call End

Review Comment:
   Yes, for consistency the finished future is now never triggered until the 
scheduler is ended, even if an error occurs (it will just enter an aborted 
state and stop accepting new tasks).  So this is no longer a concern.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to