diff --git a/include/ylt/coro_io/client_pool.hpp b/include/ylt/coro_io/client_pool.hpp index e7387e213c..2d1a73d1ca 100644 --- a/include/ylt/coro_io/client_pool.hpp +++ b/include/ylt/coro_io/client_pool.hpp @@ -123,7 +123,7 @@ class client_pool : public std::enable_shared_from_this< async_simple::coro::Lazy reconnect(std::unique_ptr& client) { auto pre_time_point = std::chrono::steady_clock::now(); bool ok = client_t::is_ok(co_await client->reconnect(host_name_)); - for (int i = 0; !ok && i < pool_config_.connect_retry_count; ++i) { + for (unsigned int i = 0; !ok && i < pool_config_.connect_retry_count; ++i) { auto post_time_point = std::chrono::steady_clock::now(); auto wait_time = pool_config_.reconnect_wait_time - (post_time_point - pre_time_point); @@ -206,11 +206,12 @@ class client_pool : public std::enable_shared_from_this< if (clients.collecter_cnt_.compare_exchange_strong(expected, 1)) { collect_idle_timeout_client( this->shared_from_this(), clients, - std::max((is_short_client - ? (std::min)(pool_config_.idle_timeout, - pool_config_.short_connect_idle_timeout) - : pool_config_.idle_timeout), - std::chrono::milliseconds{50}), + (std::max)( + (is_short_client + ? (std::min)(pool_config_.idle_timeout, + pool_config_.short_connect_idle_timeout) + : pool_config_.idle_timeout), + std::chrono::milliseconds{50}), pool_config_.idle_queue_per_max_clear_count) .via(coro_io::get_global_executor()) .start([](auto&&) { @@ -283,8 +284,7 @@ class client_pool : public std::enable_shared_from_this< : host_name_(host_name), pool_config_(pool_config), io_context_pool_(io_context_pool), - free_clients_(pool_config.max_connection) { - }; + free_clients_(pool_config.max_connection){}; client_pool(private_construct_token t, client_pools_t* pools_manager_, std::string_view host_name, const pool_config& pool_config, @@ -293,8 +293,7 @@ class client_pool : public std::enable_shared_from_this< host_name_(host_name), pool_config_(pool_config), io_context_pool_(io_context_pool), - free_clients_(pool_config.max_connection) { - }; + free_clients_(pool_config.max_connection){}; template async_simple::coro::Lazy> send_request( diff --git a/include/ylt/coro_io/detail/client_queue.hpp b/include/ylt/coro_io/detail/client_queue.hpp index 42ef53bc98..06bb6aab28 100644 --- a/include/ylt/coro_io/detail/client_queue.hpp +++ b/include/ylt/coro_io/detail/client_queue.hpp @@ -15,7 +15,6 @@ */ #pragma once #include -#include #include "ylt/util/concurrentqueue.h" namespace coro_io::detail { @@ -49,9 +48,7 @@ class client_queue { : queue_{moodycamel::ConcurrentQueue{reserve_size}, moodycamel::ConcurrentQueue{reserve_size}} {}; std::size_t size() const noexcept { return size_[0] + size_[1]; } - void reselect() noexcept { - const int_fast16_t index = (selected_index_ ^= 1); - } + void reselect() noexcept { selected_index_ ^= 1; } std::size_t enqueue(client_t&& c) { const int_fast16_t index = selected_index_; auto cnt = ++size_[index]; @@ -77,7 +74,7 @@ class client_queue { } return false; } - std::size_t clear_old(int max_clear_cnt) { + std::size_t clear_old(std::size_t max_clear_cnt) { const int_fast16_t index = selected_index_ ^ 1; if (size_[index]) { std::size_t result = diff --git a/include/ylt/coro_io/io_context_pool.hpp b/include/ylt/coro_io/io_context_pool.hpp index 2f9cd5cc2c..a740b0392b 100644 --- a/include/ylt/coro_io/io_context_pool.hpp +++ b/include/ylt/coro_io/io_context_pool.hpp @@ -193,7 +193,7 @@ class multithread_context_pool { ~multithread_context_pool() { stop(); } void run() { - for (int i = 0; i < thd_num_; i++) { + for (std::size_t i = 0; i < thd_num_; i++) { thds_.emplace_back([this] { ioc_.run(); }); diff --git a/include/ylt/util/meta_string.hpp b/include/ylt/util/meta_string.hpp index ecd53f05bd..9b3bad9e66 100644 --- a/include/ylt/util/meta_string.hpp +++ b/include/ylt/util/meta_string.hpp @@ -130,7 +130,7 @@ struct meta_string { constexpr size_t n = substr_len(pos, count); meta_string result; - for (int i = 0; i < n; ++i) { + for (std::size_t i = 0; i < n; ++i) { result[i] = elements_[pos + i]; } return result; diff --git a/src/coro_io/tests/test_channel.cpp b/src/coro_io/tests/test_channel.cpp index 9642562660..836e049e4b 100644 --- a/src/coro_io/tests/test_channel.cpp +++ b/src/coro_io/tests/test_channel.cpp @@ -79,9 +79,8 @@ TEST_CASE("test single host") { auto channel = coro_io::channel::create(hosts); for (int i = 0; i < 100; ++i) { auto res = co_await channel.send_request( - [&i, &hosts]( - coro_rpc::coro_rpc_client &client, - std::string_view host) -> async_simple::coro::Lazy { + [&hosts](coro_rpc::coro_rpc_client &client, + std::string_view host) -> async_simple::coro::Lazy { CHECK(host == hosts[0]); co_return; });