X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Control%2FConcurrent%2FChan.hs;h=2255c4e49c9450566bbd1dfbe7980e80c499b615;hb=41e8fba828acbae1751628af50849f5352b27873;hp=12f75c997c42d26431c8ded13d09b8556630ea6d;hpb=d07c47f3080ebae7bed4a94c258a90f07d911415;p=ghc-base.git diff --git a/Control/Concurrent/Chan.hs b/Control/Concurrent/Chan.hs index 12f75c9..2255c4e 100644 --- a/Control/Concurrent/Chan.hs +++ b/Control/Concurrent/Chan.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ----------------------------------------------------------------------------- -- | -- Module : Control.Concurrent.Chan @@ -46,6 +48,7 @@ import Data.Typeable data Chan a = Chan (MVar (Stream a)) (MVar (Stream a)) + deriving Eq INSTANCE_TYPEABLE1(Chan,chanTc,"Chan") @@ -93,6 +96,9 @@ readChan (Chan readVar _) = do -- either channel from then on will be available from both. Hence this creates -- a kind of broadcast channel, where data written by anyone is seen by -- everyone else. +-- +-- (Note that a duplicated channel is not equal to its original. +-- So: @fmap (c /=) $ dupChan c@ returns @True@ for all @c@.) dupChan :: Chan a -> IO (Chan a) dupChan (Chan _ writeVar) = do hole <- readMVar writeVar @@ -106,6 +112,7 @@ unGetChan (Chan readVar _) val = do modifyMVar_ readVar $ \read_end -> do putMVar new_read_end (ChItem val read_end) return new_read_end +{-# DEPRECATED unGetChan "if you need this operation, use Control.Concurrent.STM.TChan instead. See http://hackage.haskell.org/trac/ghc/ticket/4154 for details" #-} -- |Returns 'True' if the supplied 'Chan' is empty. isEmptyChan :: Chan a -> IO Bool @@ -114,6 +121,7 @@ isEmptyChan (Chan readVar writeVar) = do w <- readMVar writeVar let eq = r == w eq `seq` return eq +{-# DEPRECATED isEmptyChan "if you need this operation, use Control.Concurrent.STM.TChan instead. See http://hackage.haskell.org/trac/ghc/ticket/4154 for details" #-} -- Operators for interfacing with functional streams.