fgerlits commented on code in PR #2282:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2282#discussion_r4274730687
##########
core-framework/include/utils/net/AsioCoro.h:
##########
@@ -57,13 +59,17 @@ inline asio::awaitable<void>
async_wait(std::chrono::steady_clock::duration dura
template<class... Types>
asio::awaitable<std::tuple<std::error_code, Types...>>
asyncOperationWithTimeout(asio::awaitable<std::tuple<std::error_code,
Types...>>&& async_operation,
std::chrono::steady_clock::duration timeout_duration) {
- using asio::experimental::awaitable_operators::operator||;
- auto operation_result = co_await(std::move(async_operation) ||
async_wait(timeout_duration)); // NOLINT
- if (operation_result.index() == 1) {
+ auto executor = co_await asio::this_coro::executor; //
NOLINT(clang-analyzer-core.CallAndMessage)
+ auto parallel_group_result = co_await
asio::experimental::make_parallel_group( //
NOLINT(clang-analyzer-core.CallAndMessage)
+ asio::co_spawn(executor, std::move(async_operation), asio::deferred),
+ asio::co_spawn(executor, async_wait(timeout_duration), asio::deferred))
+ .async_wait(asio::experimental::wait_for_one_success(),
asio::use_awaitable);
+ // parallel_group_result is a tuple<std::array<std::size_t, 2>,
std::exception_ptr, std::tuple<std::error_code, Types...>, std::exception_ptr>
Review Comment:
yes, good idea, done in b23477b1962fe784c98a99adf4c462d1b237cf65
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]