Replace OnceLock<()> with better(?) alternatives

This commit is contained in:
Johannes Altmanninger
2026-04-23 18:24:52 +08:00
parent f7c336021b
commit c33ca660e3
2 changed files with 6 additions and 9 deletions

View File

@@ -1,3 +1,4 @@
use crate::global_safety::RelaxedAtomicBool;
// Generic output functions.
use crate::prelude::*;
use crate::{
@@ -14,10 +15,7 @@
cell::{RefCell, RefMut},
ops::{Deref, DerefMut},
os::{fd::RawFd, unix::ffi::OsStrExt as _},
sync::{
OnceLock,
atomic::{AtomicU8, Ordering},
},
sync::atomic::{AtomicU8, Ordering},
};
bitflags! {
@@ -189,8 +187,8 @@ fn osc_133_prompt_start(out: &mut Outputter) -> bool {
if !fish_feature_flags::feature_test(FeatureFlag::MarkPrompt) {
return false;
}
static TEST_BALLOON: OnceLock<()> = OnceLock::new();
if TEST_BALLOON.set(()).is_ok() {
static TEST_BALLOON: RelaxedAtomicBool = RelaxedAtomicBool::new(false);
if !TEST_BALLOON.swap(true) {
write_to_output!(out, "\x1b]133;A;click_events=1\x1b\\");
} else {
write_to_output!(out, "\x1b]133;A;click_events=1\x07");

View File

@@ -12,13 +12,12 @@
use std::collections::HashMap;
use std::env::set_current_dir;
use std::path::PathBuf;
use std::sync::OnceLock;
pub use serial_test::serial;
pub fn test_init() {
static DONE: OnceLock<()> = OnceLock::new();
DONE.get_or_init(|| {
static DONE: std::sync::Once = std::sync::Once::new();
DONE.call_once(|| {
// If we are building with `cargo build` and have build w/ `cmake`, this might not
// yet exist.
let mut test_dir = PathBuf::from(BUILD_DIR);