shithub: mc

Download patch

ref: 92847c0604e5f4fa790b1783595e8a503ad271be
parent: 96641430b332facfacc55f6060d0425886f35697
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Aug 11 10:52:29 EDT 2018

Clean up the mutex code a bit more.

--- a/lib/thread/mutex+futex.myr
+++ b/lib/thread/mutex+futex.myr
@@ -67,13 +67,9 @@
 	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
+	if xchg(&mtx._state, Unlocked) == Contended
+		ftxwake(&mtx._state)
 	;;
-
-	/* Contended case: set the state to unlocked and wake one thread */
-	mtx._state = Unlocked
-	ftxwake(&mtx._state)
 }
 
 const mtxcontended = {mtx