Skip to content

Commit 1427463

Browse files
committed
Make backtrace use parking_lot RawMutex
1 parent 3542a6f commit 1427463

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/libstd/sys_common/backtrace.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use io;
1717
use str;
1818
use sync::atomic::{self, Ordering};
1919
use path::{self, Path};
20-
use sys::mutex::Mutex;
20+
use sys_common::parking_lot::raw_mutex::RawMutex;
2121
use ptr;
2222

2323
pub use sys::backtrace::{
@@ -50,16 +50,14 @@ const MAX_NB_FRAMES: usize = 100;
5050

5151
/// Prints the current backtrace.
5252
pub fn print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> {
53-
static LOCK: Mutex = Mutex::new();
53+
static LOCK: RawMutex = RawMutex::INIT;
5454

5555
// Use a lock to prevent mixed output in multithreading context.
5656
// Some platforms also requires it, like `SymFromAddr` on Windows.
57-
unsafe {
58-
LOCK.lock();
59-
let res = _print(w, format);
60-
LOCK.unlock();
61-
res
62-
}
57+
LOCK.lock();
58+
let res = _print(w, format);
59+
LOCK.unlock();
60+
res
6361
}
6462

6563
fn _print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> {

0 commit comments

Comments
 (0)