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

Removed once_cell usage where possible now that Mutex::new and RwLock… #2460

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static CONFIG: Lazy<RwLock<Configuration>> = Lazy::new(|| {
//
// This allows us to inject event into the event loop without going through `ndk-glue` and
// calling unsafe function that should only be called by Android.
static INTERNAL_EVENT: Lazy<RwLock<Option<InternalEvent>>> = Lazy::new(|| RwLock::new(None));
static INTERNAL_EVENT: RwLock<Option<InternalEvent>> = RwLock::new(None);

enum InternalEvent {
RedrawRequested,
Expand Down
3 changes: 1 addition & 2 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,7 @@ impl Window {

/// Hooks for X11 errors.
#[cfg(feature = "x11")]
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(feature = "x11")]
unsafe extern "C" fn x_error_callback(
Expand Down
4 changes: 1 addition & 3 deletions src/platform_impl/linux/x11/ime/input_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ use std::{
sync::{Arc, Mutex},
};

use once_cell::sync::Lazy;

use super::{ffi, util, XConnection, XError};

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();
Expand Down
4 changes: 1 addition & 3 deletions src/platform_impl/linux/x11/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use std::os::raw::*;
use std::slice;
use std::sync::Mutex;

use once_cell::sync::Lazy;

use super::{
ffi::{
RRCrtc, RRCrtcChangeNotifyMask, RRMode, RROutputPropertyNotifyMask,
Expand All @@ -20,7 +18,7 @@ use crate::{
// Used for testing. This should always be committed as false.
const DISABLE_MONITOR_LIST_CACHING: bool = false;

static MONITORS: Lazy<Mutex<Option<Vec<MonitorHandle>>>> = Lazy::new(Mutex::default);
static MONITORS: Mutex<Option<Vec<MonitorHandle>>> = Mutex::new(None);

pub fn invalidate_cached_monitor_list() -> Option<Vec<MonitorHandle>> {
// We update this lazily.
Expand Down
8 changes: 3 additions & 5 deletions src/platform_impl/linux/x11/util/wm.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::sync::Mutex;

use once_cell::sync::Lazy;

use super::*;

// This info is global to the window manager.
static SUPPORTED_HINTS: Lazy<Mutex<Vec<ffi::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<ffi::Atom>> = Mutex::new(Vec::new());

static WM_NAME: Mutex<Option<String>> = Mutex::new(None);

pub fn hint_is_supported(hint: ffi::Atom) -> bool {
(*SUPPORTED_HINTS.lock().unwrap()).contains(&hint)
Expand Down