Remove a few unnecessary usages of Lazy (#3531)
* Convert usage of Lazy to OnceLock on macOS and iOS * Remove a few uses of Lazy that wrapped Mutex or RwLock The `new` functions on these were made `const` in Rust 1.63.0 * Use AtomicBool instead of RwLock
This commit is contained in:
parent
a5dbd3ee52
commit
c4e6e94b80
6 changed files with 51 additions and 52 deletions
|
|
@ -647,8 +647,7 @@ pub(crate) enum PlatformCustomCursor {
|
|||
|
||||
/// Hooks for X11 errors.
|
||||
#[cfg(x11_platform)]
|
||||
pub(crate) static mut XLIB_ERROR_HOOKS: Lazy<Mutex<Vec<XlibErrorHook>>> =
|
||||
Lazy::new(|| Mutex::new(Vec::new()));
|
||||
pub(crate) static mut XLIB_ERROR_HOOKS: Mutex<Vec<XlibErrorHook>> = Mutex::new(Vec::new());
|
||||
|
||||
#[cfg(x11_platform)]
|
||||
unsafe extern "C" fn x_error_callback(
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@ use std::{
|
|||
};
|
||||
|
||||
use super::{super::atoms::*, ffi, util, XConnection, XError};
|
||||
use crate::utils::Lazy;
|
||||
use x11rb::protocol::xproto;
|
||||
|
||||
static GLOBAL_LOCK: Lazy<Mutex<()>> = Lazy::new(Default::default);
|
||||
static GLOBAL_LOCK: Mutex<()> = Mutex::new(());
|
||||
|
||||
unsafe fn open_im(xconn: &Arc<XConnection>, locale_modifiers: &CStr) -> Option<ffi::XIM> {
|
||||
let _lock = GLOBAL_LOCK.lock();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use std::sync::Mutex;
|
||||
|
||||
use crate::utils::Lazy;
|
||||
|
||||
use super::*;
|
||||
|
||||
// https://specifications.freedesktop.org/wm-spec/latest/ar01s04.html#idm46075117309248
|
||||
|
|
@ -16,9 +14,8 @@ pub const MOVERESIZE_LEFT: isize = 7;
|
|||
pub const MOVERESIZE_MOVE: isize = 8;
|
||||
|
||||
// This info is global to the window manager.
|
||||
static SUPPORTED_HINTS: Lazy<Mutex<Vec<xproto::Atom>>> =
|
||||
Lazy::new(|| Mutex::new(Vec::with_capacity(0)));
|
||||
static WM_NAME: Lazy<Mutex<Option<String>>> = Lazy::new(|| Mutex::new(None));
|
||||
static SUPPORTED_HINTS: Mutex<Vec<xproto::Atom>> = Mutex::new(Vec::new());
|
||||
static WM_NAME: Mutex<Option<String>> = Mutex::new(None);
|
||||
|
||||
pub fn hint_is_supported(hint: xproto::Atom) -> bool {
|
||||
(*SUPPORTED_HINTS.lock().unwrap()).contains(&hint)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue