_TimingWheel

A timing wheel in a hierarchical set of timing wheels. Each wheel covers 6 bits of precision.

class ref _TimingWheel

Constructors

create

new ref create(
  index: USize val)
: _TimingWheel ref^

Parameters

Returns


Public Functions

schedule

Schedule a timer on this wheel. Mark the bit indicating that the given slot has timers in its list.

fun ref schedule(
  timer: Timer ref)
: None val

Parameters

Returns


advance

Remove pending timers from this timing wheel and put them on the pending list supplied. Needs the current time and the elapsed time since the previous advance. Returns true if the next timing wheel in the hierarchy should be advanced.

fun ref advance(
  list: List[Timer ref] ref,
  current: U64 val,
  elapsed: U64 val)
: Bool val

Parameters

Returns


next

Given a current time, return the next time at which this timing wheel should be advanced. Returns -1 if no timers are on this timing wheel.

fun box next(
  current: U64 val)
: U64 val

Parameters

  • current: U64 val

Returns


clear

Cancels all pending timers.

fun ref clear()
: None val

Returns


Private Functions

_slot

Return the slot for a given time.

fun box _slot(
  time: U64 val)
: U64 val

Parameters

  • time: U64 val

Returns


_bits

fun tag _bits()
: USize val

Returns


_max

fun tag _max()
: USize val

Returns


_mask

fun tag _mask()
: U64 val

Returns