std: use sync::Mutex for internal statics

This commit is contained in:
joboet
2022-09-03 14:21:38 +02:00
parent fa0ca783f8
commit 2d2c9e4493
7 changed files with 47 additions and 123 deletions

View File

@@ -7,15 +7,14 @@ use crate::fmt;
use crate::io;
use crate::io::prelude::*;
use crate::path::{self, Path, PathBuf};
use crate::sys_common::mutex::StaticMutex;
use crate::sync::{Mutex, PoisonError};
/// Max number of frames to print.
const MAX_NB_FRAMES: usize = 100;
// SAFETY: Don't attempt to lock this reentrantly.
pub unsafe fn lock() -> impl Drop {
static LOCK: StaticMutex = StaticMutex::new();
LOCK.lock()
pub fn lock() -> impl Drop {
static LOCK: Mutex<()> = Mutex::new(());
LOCK.lock().unwrap_or_else(PoisonError::into_inner)
}
/// Prints the current backtrace.