Skip to content

Commit

Permalink
ssx: Optimize the implementation of handle_shutdown_exceptions
Browse files Browse the repository at this point in the history
Create less of a continuation chain by handling all the exceptions in a
single coroutine.

Signed-off-by: Tyler Rockwood <[email protected]>
  • Loading branch information
rockwotj committed Jul 26, 2023
1 parent 114da28 commit 9670361
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/v/ssx/future-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,14 @@ inline constexpr detail::background_t background;
/// \brief Create a new future, handling common shutdown exception types.
inline seastar::future<>
ignore_shutdown_exceptions(seastar::future<> fut) noexcept {
return std::move(fut)
.handle_exception_type([](const seastar::abort_requested_exception&) {})
.handle_exception_type([](const seastar::gate_closed_exception&) {})
.handle_exception_type([](const seastar::broken_semaphore&) {})
.handle_exception_type([](const seastar::broken_promise&) {})
.handle_exception_type([](const seastar::broken_condition_variable&) {});
try {
co_await std::move(fut);
} catch (const seastar::abort_requested_exception&) {
} catch (const seastar::gate_closed_exception&) {
} catch (const seastar::broken_semaphore&) {
} catch (const seastar::broken_promise&) {
} catch (const seastar::broken_condition_variable&) {
}
}

/// \brief Check if the exception is a commonly ignored shutdown exception.
Expand Down

0 comments on commit 9670361

Please sign in to comment.