b88a62f805
This fixes several issues: * There was a bug in the cycle detection. It was possible for the cycle detection to fail because the current thread isn't in the list. Fix this by just seeing if any of the next threads were already in the cycle. * By way of an optimization the thread_waiting_on bookkeeping was done under the same thread_load_mutex as the cycle detection. But there is also an early exit after yields. If we exit through the yield the thread_waiting_on entry is stale and can cause other threads to fail to do cycle detection. * When multiple threads end up finishing a resource simultaneously anyway, probably through cycle detection, there's a small chance that the original thread finished more-or-less at the same time if the original thing blocking load completed. We solve this now by letting only one of the threads do the initial registration.