[project @ 1996-06-27 16:55:06 by partain]
[ghc-hetmet.git] / ghc / lib / concurrent / SampleVar.hs
similarity index 83%
rename from ghc/lib/prelude/SampleVar.lhs
rename to ghc/lib/concurrent/SampleVar.hs
index ca8fea4..e0f38c9 100644 (file)
@@ -1,3 +1,4 @@
+{-
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1995
 %
@@ -15,11 +16,11 @@ potentially, wakes up a blocked reader  (same as for @putMVar@ on empty @MVar@).
 \item Writing to a filled @SampleVar@ overwrites the current value.
  (different from @putMVar@ on full @MVar@.)
 \end{itemize}
+-}
 
-\begin{code}
 module SampleVar
        (
-         SampleVar(..),    --:: type _ =
+         SampleVar,        --:: type _ =
  
          newSampleVar,     --:: IO (SampleVar a)
         emptySampleVar,   --:: SampleVar a -> IO ()
@@ -28,25 +29,15 @@ module SampleVar
 
        ) where
 
-import PreludeGlaST
-import PreludePrimIO   ( newEmptyMVar, newMVar, putMVar,
-                         readMVar, swapMVar, takeMVar, _MVar
-                       )
-\end{code}
-
-\begin{code}
+import GHCbase
 
 type SampleVar a
- = _MVar (Int,         -- 1  == full
+ = MVar (Int,          -- 1  == full
                        -- 0  == empty
                        -- <0 no of readers blocked
-          _MVar a)
-
-\end{code}
+          MVar a)
 
-Initally, a @SampleVar@ is empty/unfilled.
-
-\begin{code}
+-- Initally, a @SampleVar@ is empty/unfilled.
 
 newSampleVar :: IO (SampleVar a)
 newSampleVar
@@ -61,12 +52,6 @@ emptySampleVar v
    else
      putMVar v (readers,var)
 
-\end{code}
-
-
-
-\begin{code}
-
 --
 -- filled => make empty and grab sample
 -- not filled => try to grab value, empty when read val.
@@ -91,5 +76,3 @@ writeSample svar v
      _ -> 
        putMVar val v >> 
        putMVar svar (min 1 (readers+1), val)
-
-\end{code}