1
0
Fork 0

Swap out lazy_static for std::sync::LazyLock

This commit is contained in:
Robbert van der Helm 2024-08-18 21:37:10 +02:00
parent 31711785e6
commit 61c79ab610
7 changed files with 16 additions and 18 deletions

View file

@ -10,6 +10,13 @@ Since there is no stable release yet, the changes are organized per day in
reverse chronological order. The main purpose of this document in its current
state is to list breaking changes.
## [2024-08-18]
### Breaking changes
- The minimum supported Rust version has been bumped to 1.80 to replace the last
uses of `lazy_static` with `std::sync::LazyLock`.
## [2024-05-05]
### Breaking changes

2
Cargo.lock generated
View file

@ -3048,7 +3048,6 @@ dependencies = [
"cpal",
"crossbeam",
"jack",
"lazy_static",
"libc",
"log",
"midi-consts",
@ -3089,7 +3088,6 @@ dependencies = [
"baseview 0.1.0 (git+https://github.com/RustAudio/baseview.git?rev=45465c5f46abed6c6ce370fffde5edc8e4cd5aa3)",
"crossbeam",
"egui-baseview",
"lazy_static",
"nih_plug",
"parking_lot 0.12.3",
"raw-window-handle 0.5.2",

View file

@ -2,7 +2,7 @@
name = "nih_plug"
version = "0.0.0"
edition = "2021"
rust-version = "1.70"
rust-version = "1.80"
authors = ["Robbert van der Helm <mail@robbertvanderhelm.nl>"]
license = "ISC"
@ -85,7 +85,6 @@ cfg-if = "1.0"
# This supports CLAP 1.1.8
clap-sys = { git = "https://github.com/robbert-vdh/clap-sys.git", branch = "feature/cstr-macro" }
crossbeam = "0.8"
lazy_static = "1.4"
log = { version = "0.4", features = ["std", "release_max_level_info"] }
midi-consts = "0.1"
nih_log = "0.3.1"

View file

@ -21,7 +21,6 @@ raw-window-handle = "0.5"
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "45465c5f46abed6c6ce370fffde5edc8e4cd5aa3" }
crossbeam = "0.8"
egui-baseview = { git = "https://github.com/BillyDM/egui-baseview.git", rev = "68c4d0e8e5c1c702a888a245f4ac50eddfdfcaed", default-features = false }
lazy_static = "1.4"
parking_lot = "0.12"
# To make the state persistable
serde = { version = "1.0", features = ["derive"] }

View file

@ -1,10 +1,9 @@
use std::sync::Arc;
use std::sync::{Arc, LazyLock};
use egui_baseview::egui::{
self, emath, vec2, Key, Response, Sense, Stroke, TextEdit, TextStyle, Ui, Vec2, Widget,
WidgetText,
};
use lazy_static::lazy_static;
use nih_plug::prelude::{Param, ParamSetter};
use parking_lot::Mutex;
@ -14,11 +13,10 @@ use super::util;
/// noramlized parameter.
const GRANULAR_DRAG_MULTIPLIER: f32 = 0.0015;
lazy_static! {
static ref DRAG_NORMALIZED_START_VALUE_MEMORY_ID: egui::Id = egui::Id::new((file!(), 0));
static ref DRAG_AMOUNT_MEMORY_ID: egui::Id = egui::Id::new((file!(), 1));
static ref VALUE_ENTRY_MEMORY_ID: egui::Id = egui::Id::new((file!(), 2));
}
static DRAG_NORMALIZED_START_VALUE_MEMORY_ID: LazyLock<egui::Id> =
LazyLock::new(|| egui::Id::new((file!(), 0)));
static DRAG_AMOUNT_MEMORY_ID: LazyLock<egui::Id> = LazyLock::new(|| egui::Id::new((file!(), 1)));
static VALUE_ENTRY_MEMORY_ID: LazyLock<egui::Id> = LazyLock::new(|| egui::Id::new((file!(), 2)));
/// A slider widget similar to [`egui::widgets::Slider`] that knows about NIH-plug parameters ranges
/// and can get values for it. The slider supports double click and control click to reset,

View file

@ -6,7 +6,7 @@
use anymap::Entry;
use crossbeam::channel;
use parking_lot::Mutex;
use std::sync::{Arc, Weak};
use std::sync::{Arc, LazyLock, Weak};
use std::thread::{self, JoinHandle};
use super::MainThreadExecutor;
@ -73,10 +73,8 @@ where
// Rust does not allow us to use the `T` and `E` type variable in statics, so this is a
// workaround to have a singleton that also works if for whatever reason there arem ultiple `T`
// and `E`s in a single process (won't happen with normal plugin usage, but sho knwos).
lazy_static::lazy_static! {
static ref HANDLE_MAP: Mutex<anymap::Map<dyn std::any::Any + Send>> =
Mutex::new(anymap::Map::new());
}
static HANDLE_MAP: LazyLock<Mutex<anymap::Map<dyn std::any::Any + Send>>> =
LazyLock::new(|| Mutex::new(anymap::Map::new()));
impl<T: Send + 'static, E: MainThreadExecutor<T> + 'static> WorkerThread<T, E> {
fn spawn() -> Self {

View file

@ -14,7 +14,6 @@ pub use clap_sys::factory::plugin_factory::{clap_plugin_factory, CLAP_PLUGIN_FAC
pub use clap_sys::host::clap_host;
pub use clap_sys::plugin::{clap_plugin, clap_plugin_descriptor};
pub use clap_sys::version::CLAP_VERSION;
pub use lazy_static::lazy_static;
/// Export one or more CLAP plugins from this library using the provided plugin types.
#[macro_export]