[Haskell-cafe] BlockedIndefinitelyOnMVar exception

Brandon Moore brandon_m_moore at yahoo.com
Thu Mar 31 16:37:41 CEST 2011


> From: Gregory Collins <greg at gregorycollins.net>

> Sent: Thu, March 31, 2011 5:03:09 AM
> 
> I find this behaviour a little annoying. Sometimes I *want* the thread
> to  block indefinitely! I.e. I want it to block until it receives a
> KillThread  exception. Is there a better way to accomplish that without
> waiting on an  MVar which will never fill? As a workaround what I've
> been doing lately is  stashing another reference to the mvar somewhere
> else (I'm guessing the  trigger condition for
> "BlockedIndefinitelyOnMVar" is "blocked and mvar  refcount == 1").

If you plan to send an exception, you must have the ThreadId saved elsewhere, 
which should prevent the BlockedIndefinitelyOnMVar exception.

http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.3.1.0/Control-Concurrent.html#t:ThreadId


Brandon




More information about the Haskell-Cafe mailing list