See also #2517.
We keep getting flaky failures with this in CI, which is annoying
because it marks the whole test run as failed and it doesn't retry.
The reason for that is because we have to use `fatalError` and can't use
`fail()` because this detection has to happen outside the main thread.
If the main thread is blocked, well, we can't rely `XCTest` to run in
the main thread.
Ultimately, we can't guarantee that CI machines will be fast enough to
ensure they don't get blocked.
The purpose of this class was to detect deadlocks. By increasing it to
30 seconds, we pretty much avoid flaky failures for slow CI machines,
but still have the ability to detect if the main thread is deadlocked
due to a locking issue.
See #2463.
If you're actively debugging and interrupt the main thread, it'll end up
asserting, which isn't very convenient.
Copied the logic from https://stackoverflow.com/a/33177600/401024. It's
not the safest code, but this only runs in tests.