Use LazyLock rather than lazy_static macro.

Bug: 364211748
Test: atest libremoteauth_jni_rust_tests
Change-Id: I6673f3c7558db9fb9f143489b80c87bcdac0c9dd
This commit is contained in:
Andrew Walbran 2024-09-03 16:05:12 +01:00
commit e8b17333eb
2 changed files with 4 additions and 8 deletions

View file

@ -13,7 +13,6 @@ rust_defaults {
rustlibs: [
"libbinder_rs",
"libjni_legacy",
"liblazy_static",
"liblog_rust",
"liblogger",
"libnum_traits",

View file

@ -21,12 +21,11 @@ use jni::objects::{GlobalRef, JMethodID, JObject, JValue};
use jni::signature::TypeSignature;
use jni::sys::{jbyteArray, jint, jlong, jvalue};
use jni::{JNIEnv, JavaVM};
use lazy_static::lazy_static;
use log::{debug, error, info};
use std::collections::HashMap;
use std::sync::{
atomic::{AtomicI64, Ordering},
Arc, Mutex,
Arc, LazyLock, Mutex,
};
/// Macro capturing the name of the function calling this macro.
@ -51,11 +50,9 @@ macro_rules! function_name {
}};
}
lazy_static! {
static ref HANDLE_MAPPING: Mutex<HashMap<i64, Arc<Mutex<JavaPlatform>>>> =
Mutex::new(HashMap::new());
static ref HANDLE_RN: AtomicI64 = AtomicI64::new(0);
}
static HANDLE_MAPPING: LazyLock<Mutex<HashMap<i64, Arc<Mutex<JavaPlatform>>>>> =
LazyLock::new(|| Mutex::new(HashMap::new()));
static HANDLE_RN: AtomicI64 = AtomicI64::new(0);
fn generate_platform_handle() -> i64 {
HANDLE_RN.fetch_add(1, Ordering::SeqCst)