X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Control%2FConcurrent%2FSampleVar.hs;h=ca68a38f76714e7d9d1761411ff68c7e9df4123f;hb=41e8fba828acbae1751628af50849f5352b27873;hp=c66241e2564e2c897b854f13fef39d7124414f7a;hpb=4c29f6f110d23b890567b8696a964bb212eba52e;p=ghc-base.git diff --git a/Control/Concurrent/SampleVar.hs b/Control/Concurrent/SampleVar.hs index c66241e..ca68a38 100644 --- a/Control/Concurrent/SampleVar.hs +++ b/Control/Concurrent/SampleVar.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + ----------------------------------------------------------------------------- -- | -- Module : Control.Concurrent.SampleVar @@ -34,6 +36,10 @@ import Control.Exception ( mask_ ) import Data.Functor ( (<$>) ) +import Data.Typeable + +#include "Typeable.h" + -- | -- Sample variables are slightly different from a normal 'MVar': -- @@ -58,6 +64,8 @@ newtype SampleVar a = SampleVar ( MVar ( Int -- 1 == full ) deriving (Eq) +INSTANCE_TYPEABLE1(SampleVar,sampleVarTc,"SampleVar") + -- |Build a new, empty, 'SampleVar' newEmptySampleVar :: IO (SampleVar a) newEmptySampleVar = do @@ -120,5 +128,5 @@ writeSampleVar (SampleVar svar) v = mask_ $ do isEmptySampleVar :: SampleVar a -> IO Bool isEmptySampleVar (SampleVar svar) = do (readers, _) <- readMVar svar - return (readers == 0) + return (readers <= 0)