-
Notifications
You must be signed in to change notification settings - Fork 221
Usleep #1597
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
base: master
Are you sure you want to change the base?
Usleep #1597
Conversation
…to MSEC_IN_SEC (name consistency)
peternewman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments, sorry it's taken so long work has been rather busy.
common/utils/Clock.cpp
Outdated
| * load of the system, a prior GOOD state is no guarantee for future proper | ||
| * timing. | ||
| */ | ||
| bool Sleep::CheckTimeGranularity(uint64_t wanted, uint64_t maxDeviation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be called Check... given it's actually usleeping. Should there not also be one that uses the defined wanting and max deviation times? Test maybe, or ideally a similar synonym.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's usleeping but it's only meant to be used to get a rough idea of how accurate usleep is after which further sleeps should be done with Usleep()
(which still remains a total crapshoot no matter what unless we/I find out if there is a way to trigger the program to be run in a real time fashion but afaik that is changing the kernel scheduler settings, so that would just be adding docs that "if the user wants really acurate timings they should do ....")
include/ola/Clock.h
Outdated
| int32_t MicroSeconds() const { return m_interval.MicroSeconds(); } | ||
|
|
||
| int64_t InMilliSeconds() const { return m_interval.InMilliSeconds(); } | ||
| int64_t InMicroSeconds() const { return m_interval.InMicroSeconds(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you correct the CamelCase of this and it's siblings to InMicroseconds (and throughout the codebase). We'll just add a note to the NEWS file like when we renamed DMXRecieved(sic) to DMXReceived.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this, should I add a note to NEWS or will you once you merge?
| } | ||
|
|
||
| void Sleep::usleep(uint32_t requested) { | ||
| timespec req; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be using the existing maths in TimeInterval rather than rewriting that code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow, we have a TimeIntervalToTimeSpec function somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(It does make sense to add such a function but I did not see any such thing listed in the header)
Adds InMicroSeconds() as wrapper for AsInt() for naming consistency.
Adds Sleep class with implementation of usleep() and granularity detection
Renames/adds some constants for consistency and use.