I am trying to lazily wait an MVar in hugs, in conjunction with
concurrent haskell:

-----
import Concurrent
import IOExts


f = do
    v <- newEmptyMVar
    c <- getContents
    forkIO (putMVar v (head c))
    r <- unsafeInterleaveIO (takeMVar v)
    return v

f2 = f >>= unsafeInterleaveIO . takeMVar

main1 = f >>= takeMVar >>= print
main2 = f2 >>= print
main3 = f2 >>= (\ x -> yield >> print x)
-----

main1 and main3 work flawlessly, but main2 aborts with "no more threads
to run". 

I think that main2 should work, because in evaluating the result of f2,
the main thread should suspend and yield.

Is there somebody who wants to enlighten me?

Vincenzo
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to