From b8a58674366467485ccf71ac018f3bc15a882a52 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 30 Nov 2022 18:25:05 +0100 Subject: [PATCH] Replace uses of Arc with Rc in Windows impl Everything is single threaded so there's no need to use Arcs. --- src/win/window.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/win/window.rs b/src/win/window.rs index 0dc9add..9c3556b 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -21,8 +21,8 @@ use std::ffi::{c_void, OsStr}; use std::marker::PhantomData; use std::os::windows::ffi::OsStrExt; use std::ptr::null_mut; +use std::rc::Rc; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; use raw_window_handle::{HasRawWindowHandle, RawWindowHandle, Win32Handle}; @@ -61,7 +61,7 @@ const WIN_FRAME_TIMER: usize = 4242; pub struct WindowHandle { hwnd: Option, - is_open: Arc, + is_open: Rc, // Ensure handle is !Send _phantom: PhantomData<*mut ()>, @@ -95,16 +95,16 @@ unsafe impl HasRawWindowHandle for WindowHandle { } struct ParentHandle { - is_open: Arc, + is_open: Rc, } impl ParentHandle { pub fn new(hwnd: HWND) -> (Self, WindowHandle) { - let is_open = Arc::new(AtomicBool::new(true)); + let is_open = Rc::new(AtomicBool::new(true)); let handle = WindowHandle { hwnd: Some(hwnd), - is_open: Arc::clone(&is_open), + is_open: Rc::clone(&is_open), _phantom: PhantomData::default(), }; @@ -400,7 +400,7 @@ struct WindowState { dw_style: u32, #[cfg(feature = "opengl")] - gl_context: Arc>, + gl_context: Rc>, } impl WindowState { @@ -419,7 +419,7 @@ pub struct Window { hwnd: HWND, #[cfg(feature = "opengl")] - gl_context: Arc>, + gl_context: Rc>, } impl Window { @@ -538,7 +538,7 @@ impl Window { // todo: manage error ^ #[cfg(feature = "opengl")] - let gl_context: Arc> = Arc::new(options.gl_config.map(|gl_config| { + let gl_context: Rc> = Rc::new(options.gl_config.map(|gl_config| { let mut handle = Win32Handle::empty(); handle.hwnd = hwnd as *mut c_void; let handle = RawWindowHandleWrapper { handle: RawWindowHandle::Win32(handle) };