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

Implement Sync + Send for HWND #3399

Closed
Ciantic opened this issue Dec 17, 2024 · 1 comment
Closed

Implement Sync + Send for HWND #3399

Ciantic opened this issue Dec 17, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Ciantic
Copy link

Ciantic commented Dec 17, 2024

Suggestion

HWND used to be a wrapper of isize, like HWND(pub isize), this meant it was also Send+Sync.

Now that HWND is:

pub struct HWND(pub *mut core::ffi::c_void);

It means it's not automatically Sync + Send. I don't see why it couldn't be Sync+Send because HWNDs are single-use values, and multiple threads and processes already use them.

My suggestion is to do this:

unsafe impl Sync for HWND {}
unsafe impl Send for HWND {}

Maybe for other handles as well?

@Ciantic Ciantic added the enhancement New feature or request label Dec 17, 2024
@kennykerr kennykerr added question Further information is requested and removed enhancement New feature or request labels Dec 17, 2024
@tim-weis
Copy link
Contributor

This has been discussed in #3169. In a nutshell, handles are used in too many different ways to mark them all as Send and Sync. As an example, DestroyWindow cannot be called from a thread other than the window's owning thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants