Skip to content

File syn_backoff.h

FileList > src > syntropic > util > syn_backoff.h

Go to the source code of this file

Exponential backoff helper with jitter (RFC 7252 style).

  • #include "../common/syn_defs.h"
  • #include <stdbool.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Backoff
Exponential backoff state.

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.

bool syn_backoff_exhausted (
    const SYN_Backoff * b
) 

Parameters:

  • b Backoff 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:

  • b Backoff context.
  • min_ms Initial delay (e.g., 1000).
  • max_ms Maximum delay (e.g., 60000).
  • factor Exponential factor (usually 2).
  • max_attempts Maximum number of attempts.

function syn_backoff_next_ms

Get the next delay in milliseconds.

uint32_t syn_backoff_next_ms (
    SYN_Backoff * b
) 

Each call increases the delay exponentially (up to max_ms). Includes RFC 7252-style jitter (1.0x to 1.5x) to avoid synchronization.

Parameters:

  • b Backoff context.

Returns:

Next delay duration in milliseconds.


function syn_backoff_reset

Reset the backoff state to the initial minimum delay.

void syn_backoff_reset (
    SYN_Backoff * b
) 

Parameters:

  • b Backoff context.


The documentation for this class was generated from the following file src/syntropic/util/syn_backoff.h