Skip to content

File syn_timer_wheel.h

FileList > sched > syn_timer_wheel.h

Go to the source code of this file

Hashed Timing Wheel Scheduler. More...

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

Classes

Type Name
struct SYN_TimerWheel
Hashed Timing Wheel Descriptor.
struct SYN_TimerWheelNode
Timer Wheel Node Structure.

Public Types

Type Name
typedef void(* SYN_TimerWheelCb

Public Functions

Type Name
SYN_Status syn_timer_wheel_add (SYN_TimerWheel * wheel, SYN_TimerWheelNode * node, uint32_t delay_ticks, SYN_TimerWheelCb cb, void * arg)
Schedule a timer in the timing wheel.
SYN_Status syn_timer_wheel_cancel (SYN_TimerWheel * wheel, SYN_TimerWheelNode * node)
Cancel a scheduled timer node.
SYN_Status syn_timer_wheel_init (SYN_TimerWheel * wheel)
Initialize a timing wheel scheduler.
size_t syn_timer_wheel_step (SYN_TimerWheel * wheel)
Advance the timing wheel by one tick and fire expired timers.

Macros

Type Name
define SYN_TIMER_WHEEL_BUCKETS 64U

Detailed Description

Implements an O(1) constant-time hashed timing wheel scheduler optimized for low-power tickless Operation with hundreds of concurrent software timers.

Public Types Documentation

typedef SYN_TimerWheelCb

typedef void(* SYN_TimerWheelCb) (void *arg);

Public Functions Documentation

function syn_timer_wheel_add

Schedule a timer in the timing wheel.

SYN_Status syn_timer_wheel_add (
    SYN_TimerWheel * wheel,
    SYN_TimerWheelNode * node,
    uint32_t delay_ticks,
    SYN_TimerWheelCb cb,
    void * arg
) 

Parameters:

  • wheel Pointer to wheel descriptor.
  • node Pointer to timer node memory.
  • delay_ticks Delay in ticks before timer fires.
  • cb Expiration callback.
  • arg Callback user argument.

Returns:

SYN_OK on success.


function syn_timer_wheel_cancel

Cancel a scheduled timer node.

SYN_Status syn_timer_wheel_cancel (
    SYN_TimerWheel * wheel,
    SYN_TimerWheelNode * node
) 

Parameters:

  • wheel Pointer to wheel descriptor.
  • node Pointer to timer node.

Returns:

SYN_OK on success.


function syn_timer_wheel_init

Initialize a timing wheel scheduler.

SYN_Status syn_timer_wheel_init (
    SYN_TimerWheel * wheel
) 

Parameters:

  • wheel Pointer to wheel descriptor.

Returns:

SYN_OK on success.


function syn_timer_wheel_step

Advance the timing wheel by one tick and fire expired timers.

size_t syn_timer_wheel_step (
    SYN_TimerWheel * wheel
) 

Parameters:

  • wheel Pointer to wheel descriptor.

Returns:

Number of timers fired during this tick step.


Macro Definition Documentation

define SYN_TIMER_WHEEL_BUCKETS

#define SYN_TIMER_WHEEL_BUCKETS `64U`


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