aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-03-13 18:40:18 +0100
committerLemonBoy <thatlemon@gmail.com>2020-03-13 18:40:18 +0100
commite496ef26dabb3a2da4821c7c0c2e4ffc6f7d86ce (patch)
tree50b089136dca1e7b999caa60a49cd3a9355575ce /lib/std/debug.zig
parentedcf8e0636c5a2674ce2b3e568929232c8cc61eb (diff)
downloadzig-e496ef26dabb3a2da4821c7c0c2e4ffc6f7d86ce.tar.gz
zig-e496ef26dabb3a2da4821c7c0c2e4ffc6f7d86ce.zip
Nicer idle wait loop
Trying to acquire twice the same mutex generates an idle loop.
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index cdbba2367b..f2c736bbba 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -278,8 +278,11 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c
// Another thread is panicking, wait for the last one to finish
// and call abort()
- // XXX: Find a nicer way to loop forever
- while (true) {}
+ // Here we sleep forever without hammering the CPU by causing a
+ // deadlock
+ var deadlock = std.Mutex.init();
+ _ = deadlock.acquire();
+ _ = deadlock.acquire();
}
},
1 => {