Commit e496ef26da

LemonBoy <thatlemon@gmail.com>
2020-03-13 18:40:18
Nicer idle wait loop
Trying to acquire twice the same mutex generates an idle loop.
1 parent edcf8e0
Changed files (1)
lib
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 => {