Okay, I suppose I ain't telling any news here, *but* *usually* people complained
about finalizers being never run. I just discovered that my finalizers are run
*too* *early*, probably because of unsafe{Perform,Interleave}IO:

Consider this fragment which will interleave two lists/streams (they're
created using something similiar getChanContents using unsafeInterleaveIO, too).

> mergeStreams :: [a] -> [b] -> IO [Either a b]
> mergeStreams a b = do
>   ch <- newChan
>   t1 <- forkIO (writeList2Chan ch (map Left a))
>   t2 <- forkIO (writeList2Chan ch (map Right b))
>   result <- getChanContents ch
>   addFinalizer result (print "fin!" >> killThread t1 >> killThread t2)
>   return result

The finalizer is run after I access the second argument of the resulting
stream, although more items are in the list. Removing the addFinalizer statement
will give the desired behaviour.
This happens both in 4.08.2 & 5.00.
-- 
Abstrakte Syntaxträume.
Volker Stolz * [EMAIL PROTECTED] * PGP + S/MIME

_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to