Is it true that an exception is always terminates the thread?

Edward Z. Yang ezyang at MIT.EDU
Tue Jan 24 16:59:04 CET 2012

Excerpts from Ryan Newton's message of Tue Jan 24 10:25:37 -0500 2012:
> This is related but somewhat tangential --
>   *Why isn't there a tryReadChan?*  It looks like it would be implementable
> with the current Chan representation in terms of tryTakeMVar.  Especially
> since isEmptyChan is deprecated this would be nice to have.
> Because of missing tryReadChan there is no non-blocking way to read data
> resident in a Chan (i.e. flush it -- in this case because I was in an
> exception handler and wanted to flush out what was left in memory in a
> Chan).  I found myself rolling my own in the form of the following data
> structure to get around this:

Aw, that's a shame, especially since there does exist a tryReadMVar, so
it seems like it ought to be possible (though I haven't checked closely.)


More information about the Glasgow-haskell-users mailing list