Skip to content

Make all the things Send, and messages Sync as well #171

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

Merged
merged 1 commit into from
May 20, 2022
Merged

Make all the things Send, and messages Sync as well #171

merged 1 commit into from
May 20, 2022

Conversation

nnmm
Copy link
Contributor

@nnmm nnmm commented May 19, 2022

This is required to make multithreading work. For instance, calling publish() on a separate thread doesn't work without these impls.

This is the first time I've needed to implement these traits, but I read up on them and I think this is correct. I believe rcl types don't generally care which thread they're on, and therefore can be Send.

@nnmm nnmm requested review from esteve and jhdcs May 19, 2022 10:32
Copy link
Collaborator

@jhdcs jhdcs left a comment

Choose a reason for hiding this comment

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

Is there a way that we can set up some tests to make sure that our assumptions about Send and Sync on the rcl types are accurate? As in, we set up a few scenarios that can only be done if the external type is truly Send or Sync, and make them part of CI? That way, if something changes within rcl that we don't expect, we don't get caught by surprise - or we can potentially warn rcl if that was not an intended change.

@@ -213,6 +213,11 @@ macro_rules! string_impl {
}
}

// SAFETY: A string is a simple data structure, and therefore not thread-specific.
unsafe impl Send for $string {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Forgive the potentially silly question, but I am not familiar with the $string syntax. What does it mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is inside a macro. $string can be either the String or WString type.

@nnmm
Copy link
Contributor Author

nnmm commented May 19, 2022

Is there a way that we can set up some tests to make sure that our assumptions about Send and Sync on the rcl types are accurate? As in, we set up a few scenarios that can only be done if the external type is truly Send or Sync, and make them part of CI? That way, if something changes within rcl that we don't expect, we don't get caught by surprise - or we can potentially warn rcl if that was not an intended change.

No, not easily. I think maybe (though I haven't checked) it's something that Miri can detect, but setting that up would be a larger undertaking.

Copy link
Collaborator

@jhdcs jhdcs left a comment

Choose a reason for hiding this comment

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

Well, in that case, I'll approve the changes as-is. We can always look into it in a new PR.

@nnmm nnmm merged commit 2ee4d7a into master May 20, 2022
@nnmm nnmm deleted the send branch May 20, 2022 11:34
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.

3 participants