unsafePerformIO and cooperative concurrency

Esa Pulkkinen esa.pulkkinen at kotiposti.net
Wed Apr 26 15:56:08 EDT 2006

In message <2E9B33CE230409489A7ED37E5E34090F04218DB9 at EUR-MSG-20.europe.corp.mic
rosoft.com>, "Simon Marlow" writes:
>One common case (perhaps the only common case) where this happens is
>hGetContents.  The lazy stream returned by hGetContents will not behave
>in a non-blocking way in a cooperative implementation.  I can't decide
>which demon to blame here: lazy I/O or cooperative concurrency :-)

Maybe the problem is in combining these demons :-). I mean, maybe the
problem is passing an unevaluated thunk containing references to
resources of one execution context into another (co-operative)
thread. deepSeq'ing the thunk (to force the side effects to take
place) in the correct context before allowing access by the other
thread should help, I think [but you lose ability to pass functions
from one thread to another, which might be worse].
  Esa Pulkkinen

More information about the Haskell-prime mailing list