111 [[nodiscard]]
auto calculate(std::size_t attempt) -> std::chrono::microseconds
146 -> std::chrono::microseconds
157 return std::chrono::microseconds{
158 static_cast<std::int64_t
>(initial *
static_cast<double>(attempt + 1))};
165 for (std::size_t i = 0; i < attempt; ++i)
169 if (factor * initial > max_count)
174 return std::chrono::microseconds{
175 static_cast<std::int64_t
>(initial * factor)};
187 -> std::chrono::microseconds
189 using rep = std::chrono::microseconds::rep;
190 rep base =
delay.count();
194 if (jitter_range <= 0)
199 std::uniform_int_distribution<rep> dist(-jitter_range, jitter_range);
200 rep jittered = base + dist(
rng_);
203 return std::chrono::microseconds{std::max(rep{1}, jittered)};
210 -> std::chrono::microseconds
233 return "exponential";
235 return "adaptive_jitter";
Calculates backoff delays for work-stealing operations.
void set_config(steal_backoff_config config)
Update the configuration.
steal_backoff_config config_
auto apply_jitter(std::chrono::microseconds delay) -> std::chrono::microseconds
Apply random jitter to a delay.
auto calculate(std::size_t attempt) -> std::chrono::microseconds
Calculate backoff delay for a given attempt number.
auto cap_delay(std::chrono::microseconds delay) const -> std::chrono::microseconds
Cap delay at maximum.
auto get_config() const -> const steal_backoff_config &
Get the current configuration.
backoff_calculator(steal_backoff_config config={})
Construct a backoff calculator with given configuration.
auto calculate_base_delay(std::size_t attempt) const -> std::chrono::microseconds
Calculate base delay without jitter or capping.
@ delay
Delay processing (attempt later)
Core threading foundation of the thread system library.
@ linear
Linearly increasing delay.
@ fixed
Fixed delay between retries.
@ exponential
Increasing boost over time.
steal_backoff_strategy
Backoff strategies for work-stealing operations.
@ adaptive_jitter
Exponential with random jitter for anti-correlation.
@ linear
Linear increase: delay = initial * (attempt + 1)
@ exponential
Exponential increase: delay = initial * 2^attempt.
@ fixed
Constant delay between steal attempts.
constexpr std::string_view to_string(log_level_v2 level) noexcept
Convert log_level_v2 to string representation.
Configuration for backoff behavior.
std::chrono::microseconds max_backoff
steal_backoff_strategy strategy
double jitter_factor
Jitter range as fraction of delay (0.0 - 1.0)
double multiplier
Multiplier for exponential backoff.
std::chrono::microseconds initial_backoff