Clean up the mutex code a bit more.
@@ -67,13 +67,9 @@ const mtxunlock = {mtx
are uncontended by the xchg() call, then it's safe to simply return;
nobody was waiting for us.
*/
- if xcas(&mtx._state, Locked, Unlocked) == Locked
- -> void
- ;;
-
- /* Contended case: set the state to unlocked and wake one thread */
- mtx._state = Unlocked
+ if xchg(&mtx._state, Unlocked) == Contended
ftxwake(&mtx._state)
+ ;;
}
const mtxcontended = {mtx
