Skip to content

gobot.Every() comment wrong and try to f() calls as equidistant as possible #966

Open
@gen2thomas

Description

@gen2thomas

For some applications a "f()" call with nearly the same duration is important. If a "f()" takes to long, the next call will be obviously to late and the used ticker will be adjusted in the background by golang. This is wrong or misleading with the comment of the Every() method, which states: "It does not wait for the previous execution of f to finish before it fires the next f."

Most users has no RT Kernel running and most likely do not tweak the system to run the gobot application with any special process scheduler. So this will lead to sometimes the distance between call will be to long or, if the implementation of "f()" is to expensive, this will always happen.

This behavior must be taken into account e.g. for implementing digital controllers.

Two ideas could simplify the life by adding some code to the existing gobot.Every() functionality:

  • an adjustment algorithm by using the ticker.Reset() function, which increases the ticker until it keeps nearly constant
  • property to return the last real duration

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions