Skip to content

Add a periodic timer #78

@leandro-lucarella-frequenz

Description

What's needed?

The current timer fires interval time after the ready() method was called, but this is not suitable for periodic timers as it will accumulate timer drift over time.

We need a timer that will periodically fire every interval time.

Proposed solution

Extend Timer to have a periodic option or create a new PeriodicTimer that will start when the timer is instantiated and will fire periodically every interval time, no matter if ready() was called or not.

If the timer fired several times before ready()/consume() was called, those fires should be queued and returned eventually.

Use cases

The resampler needs this.

Alternatives and workarounds

One could use the current Timer and account for the time drifting oneself. But for that we need to create a new timer for each period, which is wasteful in terms of resources (allocations) and inconvenient in terms of programming effort.

Additional context

Metadata

Metadata

Labels

part:coreAffects the core types (`Sender`, `Receiver`, exceptions, etc.)priority:highAddress this as soon as possibletype:enhancementNew feature or enhancement visitble to users

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions