mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
std.Progress: use a recursive mutex for stderr
This commit is contained in:
parent
506b3f6db6
commit
fad223d92e
@ -521,6 +521,8 @@ fn windowsApiUpdateThreadRun() void {
|
||||
/// Allows the caller to freely write to stderr until `unlockStdErr` is called.
|
||||
///
|
||||
/// During the lock, any `std.Progress` information is cleared from the terminal.
|
||||
///
|
||||
/// The lock is recursive; the same thread may hold the lock multiple times.
|
||||
pub fn lockStdErr() void {
|
||||
stderr_mutex.lock();
|
||||
clearWrittenWithEscapeCodes() catch {};
|
||||
@ -1378,4 +1380,7 @@ const have_sigwinch = switch (builtin.os.tag) {
|
||||
else => false,
|
||||
};
|
||||
|
||||
var stderr_mutex: std.Thread.Mutex = .{};
|
||||
/// The primary motivation for recursive mutex here is so that a panic while
|
||||
/// stderr mutex is held still dumps the stack trace and other debug
|
||||
/// information.
|
||||
var stderr_mutex = std.Thread.Mutex.Recursive.init;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user