Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance: Fix EventScheduler::timeRemaining() comment #1916

Conversation

rousskov
Copy link
Contributor

No description provided.

@@ -204,7 +204,7 @@ EventScheduler::timeRemaining() const
if (tasks->when <= current_dtime) // we are on time or late
return 0; // fire the event ASAP

const double diff = tasks->when - current_dtime; // microseconds
const double diff = tasks->when - current_dtime; // seconds
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change the type of diff variable to auto because this code secretly relies on diff type being an arithmetic type. For example, when using std::chrono::duration for diff, 1000*diff expression below will compile but will not convert seconds to milliseconds as intended. Event::when type, this whole method (including its return type), and method callers should be reworked using std::chrono, but this is a minimal PR fixing (my 2013 commit aa14d75) bug that wasted 30 minutes of my time.

Said that, if you insist on auto upgrade, just apply this suggestion:

Suggested change
const double diff = tasks->when - current_dtime; // seconds
const auto diff = tasks->when - current_dtime; // seconds

@rousskov rousskov added M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels S-could-use-an-approval An approval may speed this PR merger (but is not required) labels Oct 13, 2024
@rousskov rousskov changed the title Maintenance: Fix wrong EventScheduler::timeRemaining() comment Maintenance: Fix EventScheduler::timeRemaining() comment Oct 13, 2024
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label Oct 15, 2024
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels labels Oct 16, 2024
@rousskov rousskov removed the S-could-use-an-approval An approval may speed this PR merger (but is not required) label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-merged https://github.com/measurement-factory/anubis#pull-request-labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants