File syn_backoff.c¶
FileList > src > syntropic > util > syn_backoff.c
Go to the source code of this file
Exponential backoff implementation.
#include "syn_backoff.h"#include "syn_assert.h"#include "syn_random.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| bool | syn_backoff_exhausted (const SYN_Backoff * b) Check if the maximum number of attempts has been reached. |
| void | syn_backoff_init (SYN_Backoff * b, uint32_t min_ms, uint32_t max_ms, uint8_t factor, uint8_t max_attempts) Initialize backoff state. |
| uint32_t | syn_backoff_next_ms (SYN_Backoff * b) Get the next delay in milliseconds. |
| void | syn_backoff_reset (SYN_Backoff * b) Reset the backoff state to the initial minimum delay. |
Public Functions Documentation¶
function syn_backoff_exhausted¶
Check if the maximum number of attempts has been reached.
Parameters:
bBackoff context.
Returns:
true if attempts >= max_attempts.
function syn_backoff_init¶
Initialize backoff state.
void syn_backoff_init (
SYN_Backoff * b,
uint32_t min_ms,
uint32_t max_ms,
uint8_t factor,
uint8_t max_attempts
)
Parameters:
bBackoff context.min_msInitial delay (e.g., 1000).max_msMaximum delay (e.g., 60000).factorExponential factor (usually 2).max_attemptsMaximum number of attempts.
function syn_backoff_next_ms¶
Get the next delay in milliseconds.
Each call increases the delay exponentially (up to max_ms). Includes RFC 7252-style jitter (1.0x to 1.5x) to avoid synchronization.
Parameters:
bBackoff context.
Returns:
Next delay duration in milliseconds.
function syn_backoff_reset¶
Reset the backoff state to the initial minimum delay.
Parameters:
bBackoff context.
The documentation for this class was generated from the following file src/syntropic/util/syn_backoff.c