Problem with hugs, concurrency and unsafeInterleaveIO (maybe a bug?)
Sat, 15 Mar 2003 20:01:32 +0100
I am trying to lazily wait an MVar in hugs, in conjunction with
f = do
v <- newEmptyMVar
c <- getContents
forkIO (putMVar v (head c))
r <- unsafeInterleaveIO (takeMVar 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
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?