call setTimeout in Countdown ctor #577
No reviewers
Labels
No Label
API Change
Breaking API Change
bug
build
cosmetics
Documentation
duplicate
feature
help wanted
hotfix
invalid
question
Refactor
Tests
wontfix
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: fsfw/fsfw#577
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "eive/fsfw:mueller/countdown-improvement-upstream"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I think this is a bit more intuitive. No need to call setTimeout after initializing the countdown with an initial value
We can do that but it is still necessary to call setTimeout or resetTimer for most apllications because Countdown is typically a member of an object which is created at boot. The time of construction will not be of any use. Even the onboard clock might not be valid at that time.
I agree with Steffen that this is probably not used much, as in a periodic FSW you need to periodically reset your timers anyway.
Do you have a specific use in mind, Robin?
I'm more worried with having unitialized Countdown having an undefined state (ie what is returnd by
hasTimedOut()
). To have it in a defined state, I would propose to instead calltimeOut()
in the ctor, to have it be timed out after ctor in most cases (Except for the ones where the time is not initialized yet. But as we get the time from the OS in all current OSALs, I suppose it should be valid at ctor time).Then we could also remove the warning
Otherwise a call to hasTimedOut might return True.
from the documentation which quite clearly shows that someone was already thinking about this undefinedness but did not think it trough (assuming that was me, in any other case, please excuse my insinuation).Yes, I have a specific use-case and I use this in the EIVE OBSW.
if a variant which does not set up the start time is required, it might also make more sense to define a constructor which does not take an initial timeout. From an C++ API perpective, the code above is the most inutitive for me, no need to call setTimeout again, simply create the countdown on stack and it's ready to use.
Ok in summary:
As such I am in favour of merging this PR.