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

Misc dds & rsutils #13704

Merged
merged 3 commits into from
Jan 27, 2025
Merged

Misc dds & rsutils #13704

merged 3 commits into from
Jan 27, 2025

Conversation

maloel
Copy link
Contributor

@maloel maloel commented Jan 23, 2025

Separated a few commits from my upcoming PR...

The functions in timer and stopwatch has bad const designations... I changed those. Sorry about the formatting...

{
namespace time
public:
stopwatch() { _start = clock::now(); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use initializer list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, changed.

}

// Block until the event is set()
// If already set, returns immediately
// The event remains set when returning: it needs to be cleared...
void wait() const
void wait()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove the const? Semantically we don't expect wait to change internal event state

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I guess wait() waits for someone else to change it - even though you're expecting a change, you're no changing it yourself...
So I'll try putting back the const.

{
std::unique_lock< std::mutex > lock( _m );
if( ! _is_set )
_is_set = ( std::cv_status::timeout != _cv.wait( lock, timeout ) );
_is_set = ( std::cv_status::timeout != _cv.wait_for( lock, timeout ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should assign _is_set here, same way we don't assign in wait() function.

Copy link
Contributor

Choose a reason for hiding this comment

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

And then the function can stay const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do so.

@@ -90,7 +93,7 @@ class event
{
std::unique_lock< std::mutex > lock( _m );
_is_set = false;
_is_set = ( std::cv_status::timeout != _cv.wait( lock, timeout ) );
_is_set = ( std::cv_status::timeout != _cv.wait_for( lock, timeout ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, don't assign _is_set here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, but note that line 95 still is needed. And this function is not const.

@maloel maloel merged commit 61c5582 into IntelRealSense:development Jan 27, 2025
22 of 23 checks passed
@maloel maloel deleted the misc-dds branch January 27, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants