Ticket #6153: Chan.diff

File Chan.diff, 1.1 KB (added by klao, 23 months ago)

patch for writeChan

Line 
1diff -cr base-4.5.0.0.orig/Control/Concurrent/Chan.hs base-4.5.0.0/Control/Concurrent/Chan.hs
2*** base-4.5.0.0.orig/Control/Concurrent/Chan.hs        Fri Feb  3 00:08:43 2012
3--- base-4.5.0.0/Control/Concurrent/Chan.hs     Fri Jun  8 20:38:16 2012
4***************
5*** 40,45 ****
6--- 40,46 ----
7 
8  import System.IO.Unsafe         ( unsafeInterleaveIO )
9  import Control.Concurrent.MVar
10+ import Control.Exception
11  import Data.Typeable
12 
13  #include "Typeable.h"
14***************
15*** 83,91 ****
16  writeChan :: Chan a -> a -> IO ()
17  writeChan (Chan _ writeVar) val = do
18    new_hole <- newEmptyMVar
19!   modifyMVar_ writeVar $ \old_hole -> do
20      putMVar old_hole (ChItem val new_hole)
21!     return new_hole
22 
23  -- |Read the next value from the 'Chan'.
24  readChan :: Chan a -> IO a
25--- 84,93 ----
26  writeChan :: Chan a -> a -> IO ()
27  writeChan (Chan _ writeVar) val = do
28    new_hole <- newEmptyMVar
29!   mask $ \_ -> do
30!     old_hole <- takeMVar writeVar
31      putMVar old_hole (ChItem val new_hole)
32!     putMVar writeVar new_hole
33 
34  -- |Read the next value from the 'Chan'.
35  readChan :: Chan a -> IO a