Skip to content

Commit 06aa544

Browse files
committed
Make Win32WindowHandle Send + Sync
1 parent 3f360ef commit 06aa544

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ mod tests {
429429
assert_not_impl_any!(WaylandWindowHandle: Send, Sync);
430430
assert_impl_all!(DrmWindowHandle: Send, Sync);
431431
assert_not_impl_any!(GbmWindowHandle: Send, Sync);
432-
assert_not_impl_any!(Win32WindowHandle: Send, Sync);
432+
assert_impl_all!(Win32WindowHandle: Send, Sync);
433433
assert_not_impl_any!(WinRtWindowHandle: Send, Sync);
434434
assert_not_impl_any!(WebCanvasWindowHandle: Send, Sync);
435435
assert_not_impl_any!(WebOffscreenCanvasWindowHandle: Send, Sync);

src/windows.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@ pub struct Win32WindowHandle {
5555
pub hinstance: Option<NonNull<c_void>>,
5656
}
5757

58+
unsafe impl Send for Win32WindowHandle {}
59+
unsafe impl Sync for Win32WindowHandle {}
60+
5861
impl Win32WindowHandle {
5962
/// Create a new handle to a window.
6063
///
6164
/// # Safety
6265
///
63-
/// It is assumed that the Win32 handle belongs to the current thread. This
64-
/// is necessary for the handle to be considered "valid" in all cases.
66+
/// Some APIs taking a `HWND` must observe its thread-affinity.
67+
/// Consumers are responsible to ensure these safety guarantees themselves.
68+
/// See [`GetWindowThreadProcessId()`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowthreadprocessid).
6569
///
6670
/// # Example
6771
///

0 commit comments

Comments
 (0)