Generalise `Control.Monad.{when,unless,guard}`
[ghc.git] / rts / RaiseAsync.c
index 11f518a..7da3e64 100644 (file)
@@ -33,9 +33,6 @@ static void removeFromQueues(Capability *cap, StgTSO *tso);
 
 static void removeFromMVarBlockedQueue (StgTSO *tso);
 
-static void blockedThrowTo (Capability *cap, 
-                            StgTSO *target, MessageThrowTo *msg);
-
 static void throwToSendMsg (Capability *cap USED_IF_THREADS,
                             Capability *target_cap USED_IF_THREADS, 
                             MessageThrowTo *msg USED_IF_THREADS);
@@ -294,6 +291,7 @@ check_target:
     }
 
     case BlockedOnMVar:
+    case BlockedOnMVarRead:
     {
        /*
          To establish ownership of this TSO, we need to acquire a
@@ -318,7 +316,7 @@ check_target:
 
         // we have the MVar, let's check whether the thread
        // is still blocked on the same MVar.
-       if (target->why_blocked != BlockedOnMVar
+       if ((target->why_blocked != BlockedOnMVar && target->why_blocked != BlockedOnMVarRead)
            || (StgMVar *)target->block_info.closure != mvar) {
            unlockClosure((StgClosure *)mvar, info);
            goto retry;
@@ -466,7 +464,7 @@ throwToSendMsg (Capability *cap STG_UNUSED,
 // Block a throwTo message on the target TSO's blocked_exceptions
 // queue.  The current Capability must own the target TSO in order to
 // modify the blocked_exceptions queue.
-static void
+void
 blockedThrowTo (Capability *cap, StgTSO *target, MessageThrowTo *msg)
 {
     debugTraceCap(DEBUG_sched, cap, "throwTo: blocking on thread %lu",
@@ -637,6 +635,7 @@ removeFromQueues(Capability *cap, StgTSO *tso)
     goto done;
 
   case BlockedOnMVar:
+  case BlockedOnMVarRead:
       removeFromMVarBlockedQueue(tso);
       goto done;
 
@@ -924,7 +923,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
            //
            sp = frame - 1;
            
-           /* Ensure that async excpetions are blocked now, so we don't get
+           /* Ensure that async exceptions are blocked now, so we don't get
             * a surprise exception before we get around to executing the
             * handler.
             */
@@ -1052,3 +1051,11 @@ done:
 }
 
 
+
+// Local Variables:
+// mode: C
+// fill-column: 80
+// indent-tabs-mode: nil
+// c-basic-offset: 4
+// buffer-file-coding-system: utf-8-unix
+// End: