Nicer idle wait loop

Trying to acquire twice the same mutex generates an idle loop.
This commit is contained in:
LemonBoy 2020-03-13 18:40:18 +01:00
parent edcf8e0636
commit e496ef26da

View File

@ -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 // Another thread is panicking, wait for the last one to finish
// and call abort() // and call abort()
// XXX: Find a nicer way to loop forever // Here we sleep forever without hammering the CPU by causing a
while (true) {} // deadlock
var deadlock = std.Mutex.init();
_ = deadlock.acquire();
_ = deadlock.acquire();
} }
}, },
1 => { 1 => {