isEmptyChan blocks?
Peter Strand
d98peter@dtek.chalmers.se
Tue, 17 Jun 2003 17:02:09 +0200
Hi,
I noticed that isEmptyChan blocks if the channel is already
waited on by readChan, is this the intended behaviour?
At least I was a bit surprised by a blocking predicate..
Example program:
import Control.Concurrent
main = do
ch <- newChan
let loop = do
threadDelay 1000000 -- make sure readChan executes
isEmptyChan ch
print "not reached"
loop
forkIO loop
readChan ch
This happens both with 5.04.2 and 6.0, on linux.
When compiled, "Fail: thread blocked indefinitely" is printed,
ghci just blocks.
The corresponding program with MVars doesn't block.
/Peter