Skip to content

Implement Sync + Send for HWND #3399

Closed
Closed

Description

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?

Activity

  1. tim-weis commented on Dec 18, 2024

    @tim-weis
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions