Add comment & polishing

This commit is contained in:
Igor Nikonov 2023-12-20 20:38:02 +00:00
parent 52db759c92
commit f46acc5236
2 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,14 @@ std::function<Priority(size_t index)> GetPriorityForLoadBalancing::getPriorityFu
case LoadBalancing::ROUND_ROBIN:
auto local_last_used = last_used.fetch_add(1) % pool_size;
// Example: pool_size = 5
// | local_last_used | i=0 | i=1 | i=2 | i=3 | i=4 |
// | 0 | 4 | 0 | 1 | 2 | 3 |
// | 1 | 3 | 4 | 0 | 1 | 2 |
// | 2 | 2 | 3 | 4 | 0 | 1 |
// | 3 | 1 | 2 | 3 | 4 | 0 |
// | 4 | 0 | 1 | 2 | 3 | 4 |
get_priority = [pool_size, local_last_used](size_t i)
{
size_t priority = pool_size - 1;

View File

@ -147,7 +147,7 @@ protected:
return std::make_tuple(shared_pool_states, nested_pools, last_error_decrease_time);
}
NestedPools nested_pools;
const NestedPools nested_pools;
const time_t decrease_error_period;
const size_t max_error_cap;