11
11
12
12
#include < fmt/ranges.h>
13
13
#include < seastar/core/when_all.hh>
14
- #include < seastar/core/loop .hh>
14
+ #include < seastar/coroutine/parallel_for_each .hh>
15
15
#include < seastar/core/reactor.hh>
16
16
17
17
namespace generic_server {
@@ -119,7 +119,7 @@ future<> server::stop() {
119
119
120
120
future<> server::shutdown () {
121
121
if (_gate.is_closed ()) {
122
- return make_ready_future<>() ;
122
+ co_return ;
123
123
}
124
124
_all_connections_stopped = _gate.close ();
125
125
size_t nr = 0 ;
@@ -129,16 +129,14 @@ future<> server::shutdown() {
129
129
l.abort_accept ();
130
130
_logger.debug (" abort accept {} out of {} done" , ++nr, nr_total);
131
131
}
132
- auto nr_conn = make_lw_shared< size_t >( 0 ) ;
132
+ size_t nr_conn = 0 ;
133
133
auto nr_conn_total = _connections_list.size ();
134
134
_logger.debug (" shutdown connection nr_total={}" , nr_conn_total);
135
- return parallel_for_each (_connections_list.begin (), _connections_list.end (), [this , nr_conn, nr_conn_total] (auto && c) {
136
- return c.shutdown ().then ([this , nr_conn, nr_conn_total] {
137
- _logger.debug (" shutdown connection {} out of {} done" , ++(*nr_conn), nr_conn_total);
138
- });
139
- }).then ([this ] {
140
- return std::move (_listeners_stopped);
135
+ co_await coroutine::parallel_for_each (_connections_list, [&] (auto && c) -> future<> {
136
+ co_await c.shutdown ();
137
+ _logger.debug (" shutdown connection {} out of {} done" , ++nr_conn, nr_conn_total);
141
138
});
139
+ co_await std::move (_listeners_stopped);
142
140
}
143
141
144
142
future<>
0 commit comments