Skip to content

Commit

Permalink
comment to remind myself why the complicated callback thing needs to …
Browse files Browse the repository at this point in the history
…happen
  • Loading branch information
paleolimbot committed Sep 14, 2022
1 parent 4edccb6 commit 4b1807a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion r/src/compute-exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,17 @@ class ExecPlanReader : public arrow::RecordBatchReader {

void StopProducing() {
if (status_ == PLAN_RUNNING) {
plan_->StopProducing();
// We're done with the plan, but it may still need some time
// to finish and clean up after itself. To do this, we give a
// callable with its own copy of the shared_ptr<ExecPlan> so
// that it can delete itself when it is safe to do so.
std::shared_ptr<arrow::compute::ExecPlan> plan(plan_);
bool not_finished_yet = plan_->finished().TryAddCallback(
[&plan] { return [plan](const arrow::Status&) {}; });

if (not_finished_yet) {
plan_->StopProducing();
}
}

status_ = PLAN_FINISHED;
Expand Down

0 comments on commit 4b1807a

Please sign in to comment.