westonpace commented on a change in pull request #9095:
URL: https://github.com/apache/arrow/pull/9095#discussion_r572267087



##########
File path: cpp/src/arrow/util/async_iterator.h
##########
@@ -0,0 +1,382 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+#include <queue>
+
+#include "arrow/util/functional.h"
+#include "arrow/util/future.h"
+#include "arrow/util/iterator.h"
+#include "arrow/util/optional.h"
+#include "arrow/util/thread_pool.h"
+
+namespace arrow {
+
+template <typename T>
+using AsyncGenerator = std::function<Future<T>()>;

Review comment:
       I have gone back and forth a little (hence this discrepancy). I don't 
think asynchronous iterators are terribly common in general.  When they are 
used (e.g. javascript) it is in conjunction with syntactic "await" sugar to 
create something that can actually be iterated (e.g. `for await...of`).  The 
only way to truly "iterate" these chains is to use the Collect/Visit utilities 
(or the underlying Loop) which I feel isn't quite the same thing.  So 
asynchronous iterator isn't an ideal name.
   
   Generator is used in python for creating an iterator with yield statements 
which is an entirely separate concept.  It's used exactly the same in 
javascript.  In fact, in javascript there is an "asynchronous generator" which 
allows you to create asynchronous functions that yield (which is not what we 
are doing there).  So the asynchronous generator name isn't perfect either.
   
   In the FRP world these might be called events and event streams but I think 
that fits a push-based model better.
   
   I think, in the interest of "perfect is the enemy of good" I will stick with 
AsyncGenerator everywhere and rename `async_iterator` to `async_generator`.




----------------------------------------------------------------
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


Reply via email to