chore: use std::sync::LazyLock
This commit is contained in:
parent
310cf212eb
commit
fec7c94605
4 changed files with 46 additions and 55 deletions
|
|
@ -4,10 +4,8 @@
|
|||
macro_rules! id_gen {
|
||||
($func_name:ident, $id_name:ident, $ids_name:ident) => {
|
||||
static $id_name: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
|
||||
lazy_static::lazy_static! {
|
||||
static ref $ids_name: std::sync::Mutex<std::collections::HashSet<usize>> =
|
||||
std::sync::Mutex::new(std::collections::HashSet::new());
|
||||
}
|
||||
static $ids_name: std::sync::LazyLock<std::sync::Mutex<std::collections::HashSet<usize>>> =
|
||||
std::sync::LazyLock::new(|| std::sync::Mutex::new(std::collections::HashSet::new()));
|
||||
|
||||
fn $func_name() -> usize {
|
||||
let mut ids = $ids_name.lock().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue