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

Should RawWindowHandle be Send? #59

Closed
glowcoil opened this issue Nov 14, 2020 · 2 comments
Closed

Should RawWindowHandle be Send? #59

glowcoil opened this issue Nov 14, 2020 · 2 comments

Comments

@glowcoil
Copy link

It looks like RawWindowHandle, and the individual platform handles, are marked !Send by default due to the pointers they contain. I couldn't find any documentation one way or another on whether this is explicitly intended to be a part of the safety contract for using a RawWindowHandle or not. I assume that there are some use cases where moving a handle between threads is perfectly safe, and others where it is not. Do existing libraries rely on RawWindowHandle not implementing Send for safety? Or would it be fine for it to impl Send?

@thomcc
Copy link

thomcc commented Jan 3, 2021

No, for the same reasons raw pointers aren't. Also, not all platforms support doing windowing operations off of the main (ui) thread.

If you need this and are sure it's sound for your use case/target, you should wrap it in a newtype struct and unsafe impl Send for it. I would definitely recommend doing this for a concrete window handle type and not the RawWindowHandle enum, however.

@glowcoil
Copy link
Author

glowcoil commented Jan 5, 2021

Sounds reasonable to me, and the newtype approach is what I've done in my own code; just wanted to hear some opinions since it isn't mentioned in the docs.

@glowcoil glowcoil closed this as completed Jan 5, 2021
@madsmtm madsmtm mentioned this issue Oct 13, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants