authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-13 18:40:18+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-13 18:40:18+01:00
loge496ef26dabb3a2da4821c7c0c2e4ffc6f7d86ce
tree50b089136dca1e7b999caa60a49cd3a9355575ce
parentedcf8e0636c5a2674ce2b3e568929232c8cc61eb

Nicer idle wait loop

Trying to acquire twice the same mutex generates an idle loop.

1 files changed, 5 insertions(+), 2 deletions(-)

lib/std/debug.zig+5-2
...@@ -278,8 +278,11 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c...@@ -278,8 +278,11 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c
278 // Another thread is panicking, wait for the last one to finish278 // Another thread is panicking, wait for the last one to finish
279 // and call abort()279 // and call abort()
280280
281 // XXX: Find a nicer way to loop forever281 // Here we sleep forever without hammering the CPU by causing a
282 while (true) {}282 // deadlock
283 var deadlock = std.Mutex.init();
284 _ = deadlock.acquire();
285 _ = deadlock.acquire();
283 }286 }
284 },287 },
285 1 => {288 1 => {