Skip to content

Commit c1c50e3

Browse files
authored
Reconnection no longer causes the writer to perform busy waiting (#253)
Reconnection now uses a separate timer to wait close #252
1 parent 328ad97 commit c1c50e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/boost/redis/connection.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,10 @@ class run_op {
442442
return;
443443
}
444444

445-
// It is safe to use the writer timer here because we are not
446-
// connected.
447-
conn_->writer_timer_.expires_after(conn_->cfg_.reconnect_wait_interval);
445+
conn_->reconnect_timer_.expires_after(conn_->cfg_.reconnect_wait_interval);
448446

449447
BOOST_ASIO_CORO_YIELD
450-
conn_->writer_timer_.async_wait(asio::prepend(std::move(self), order_t{}));
448+
conn_->reconnect_timer_.async_wait(asio::prepend(std::move(self), order_t{}));
451449
if (ec0) {
452450
self.complete(ec0);
453451
return;
@@ -507,6 +505,7 @@ class basic_connection {
507505
: ctx_{std::move(ctx)}
508506
, stream_{std::make_unique<next_layer_type>(ex, ctx_)}
509507
, writer_timer_{ex}
508+
, reconnect_timer_{ex}
510509
, receive_channel_{ex, 256}
511510
, resv_{ex}
512511
, health_checker_{ex}
@@ -826,6 +825,7 @@ class basic_connection {
826825
// also more suitable than a channel and the notify operation does
827826
// not suspend.
828827
timer_type writer_timer_;
828+
timer_type reconnect_timer_; // to wait the reconnection period
829829
receive_channel_type receive_channel_;
830830
resolver_type resv_;
831831
detail::connector ctor_;

0 commit comments

Comments
 (0)