Skip to content

Commit

Permalink
fix msic
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Aug 10, 2023
1 parent 42f5fe0 commit 734806e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
19 changes: 9 additions & 10 deletions include/ylt/coro_io/client_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class client_pool : public std::enable_shared_from_this<
async_simple::coro::Lazy<void> reconnect(std::unique_ptr<client_t>& 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);
Expand Down Expand Up @@ -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&&) {
Expand Down Expand Up @@ -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,
Expand All @@ -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 <typename T>
async_simple::coro::Lazy<return_type<T>> send_request(
Expand Down
7 changes: 2 additions & 5 deletions include/ylt/coro_io/detail/client_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
#pragma once
#include <atomic>
#include <iterator>

#include "ylt/util/concurrentqueue.h"
namespace coro_io::detail {
Expand Down Expand Up @@ -49,9 +48,7 @@ class client_queue {
: queue_{moodycamel::ConcurrentQueue<client_t>{reserve_size},
moodycamel::ConcurrentQueue<client_t>{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];
Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/coro_io/io_context_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/util/meta_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct meta_string {
constexpr size_t n = substr_len(pos, count);

meta_string<n> result;
for (int i = 0; i < n; ++i) {
for (std::size_t i = 0; i < n; ++i) {
result[i] = elements_[pos + i];
}
return result;
Expand Down
5 changes: 2 additions & 3 deletions src/coro_io/tests/test_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ TEST_CASE("test single host") {
auto channel = coro_io::channel<coro_rpc::coro_rpc_client>::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<void> {
[&hosts](coro_rpc::coro_rpc_client &client,
std::string_view host) -> async_simple::coro::Lazy<void> {
CHECK(host == hosts[0]);
co_return;
});
Expand Down

0 comments on commit 734806e

Please sign in to comment.