Skip to content

Commit acc6c2e

Browse files
westonpacelidavidm
authored andcommitted
ARROW-15968: [C++] Update AsyncGenerator semantics to emit a terminal item only after all outstanding futures have completed
Unfortunately, this seems to have made the merge generator, which was already quite complicated, even more complicated. I'd welcome any suggestions for simplification. In the meantime, even though this one generator is more complicated, I think this allows us to simplify code using async generators considerably. This is a prerequisite for apache#12468 because there is no way to keep the serial generator alive after the async generator has been destroyed (we can't use shared_ptr in this case) Closes apache#12662 from westonpace/feature/ARROW-15968--only-emit-terminal-items-when-outstanding-tasks-finished Authored-by: Weston Pace <weston.pace@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
1 parent d6a89e5 commit acc6c2e

3 files changed

Lines changed: 507 additions & 54 deletions

File tree

cpp/src/arrow/testing/gtest_util.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,10 @@ class GatingTask::Impl : public std::enable_shared_from_this<GatingTask::Impl> {
959959
}
960960

961961
Future<> AsyncTask() {
962+
std::lock_guard<std::mutex> lk(mx_);
962963
num_launched_++;
963964
num_running_++;
965+
running_cv_.notify_all();
964966
/// TODO(ARROW-13004) Could maybe implement this check with future chains
965967
/// if we check to see if the future has been "consumed" or not
966968
num_finished_++;

0 commit comments

Comments
 (0)