Skip to content

Conversation

@Keeper-of-the-Keys
Copy link

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.

Copy link
Member

@peternewman peternewman left a 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.

* load of the system, a prior GOOD state is no guarantee for future proper
* timing.
*/
bool Sleep::CheckTimeGranularity(uint64_t wanted, uint64_t maxDeviation) {
Copy link
Member

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.

Copy link
Author

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 ....")

int32_t MicroSeconds() const { return m_interval.MicroSeconds(); }

int64_t InMilliSeconds() const { return m_interval.InMilliSeconds(); }
int64_t InMicroSeconds() const { return m_interval.InMicroSeconds(); }
Copy link
Member

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.

Copy link
Author

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;
Copy link
Member

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.

Copy link
Author

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?

Copy link
Author

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)

@peternewman peternewman added this to the 0.11.0 milestone Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants