pitrou commented on a change in pull request #9528: URL: https://github.com/apache/arrow/pull/9528#discussion_r588183511
########## File path: cpp/src/arrow/util/thread_pool.cc ########## @@ -91,12 +101,20 @@ static void WorkerLoop(std::shared_ptr<ThreadPool::State> state, --state->ready_count_; DCHECK_GE(state->ready_count_, 0); { - FnOnce<void()> task = std::move(state->pending_tasks_.front()); + Task task = std::move(state->pending_tasks_.front()); state->pending_tasks_.pop_front(); + StopToken* stop_token = &task.stop_token; lock.unlock(); - std::move(task)(); + if (!stop_token->IsStopRequested()) { + std::move(task.callable)(); + } else { + if (task.stop_callback) { + std::move(task.stop_callback)(stop_token->Poll()); + } + } + ARROW_UNUSED(std::move(task)); // release resources before waiting for lock + lock.lock(); Review comment: Note to self: better to re-lock outside of scope? (to let `task` be destroyed) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org