westonpace commented on a change in pull request #9095: URL: https://github.com/apache/arrow/pull/9095#discussion_r555261490
########## File path: cpp/src/arrow/util/iterator_test.cc ########## @@ -129,11 +130,47 @@ template <typename T> inline Iterator<T> EmptyIt() { return MakeEmptyIterator<T>(); } - inline Iterator<TestInt> VectorIt(std::vector<TestInt> v) { return MakeVectorIterator<TestInt>(std::move(v)); } +std::function<Future<TestInt>()> AsyncVectorIt(std::vector<TestInt> v) { + auto index = std::make_shared<size_t>(0); + auto vec = std::make_shared<std::vector<TestInt>>(std::move(v)); + return [index, vec]() -> Future<TestInt> { + if (*index >= vec->size()) { + return Future<TestInt>::MakeFinished(IterationTraits<TestInt>::End()); + } + auto next = (*vec)[*index]; + (*index)++; + return Future<TestInt>::MakeFinished(next); + }; Review comment: This is good. I changed all of the tests in iterator_test.cc to make use of captured lambda state instead of shared pointer state. ---------------------------------------------------------------- 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