projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[project @ 1996-06-27 16:55:06 by partain]
[ghc-hetmet.git]
/
ghc
/
lib
/
concurrent
/
SampleVar.hs
diff --git
a/ghc/lib/prelude/SampleVar.lhs
b/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)
--- a/
ghc/lib/prelude/SampleVar.lhs
+++ b/
ghc/lib/concurrent/SampleVar.hs
@@
-1,3
+1,4
@@
+{-
%
% (c) The GRASP/AQUA Project, Glasgow University, 1995
%
%
% (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}
\item Writing to a filled @SampleVar@ overwrites the current value.
(different from @putMVar@ on full @MVar@.)
\end{itemize}
+-}
-\begin{code}
module SampleVar
(
module SampleVar
(
- SampleVar(..), --:: type _ =
+ SampleVar, --:: type _ =
newSampleVar, --:: IO (SampleVar a)
emptySampleVar, --:: SampleVar a -> IO ()
newSampleVar, --:: IO (SampleVar a)
emptySampleVar, --:: SampleVar a -> IO ()
@@
-28,25
+29,15
@@
module SampleVar
) where
) where
-import PreludeGlaST
-import PreludePrimIO ( newEmptyMVar, newMVar, putMVar,
- readMVar, swapMVar, takeMVar, _MVar
- )
-\end{code}
-
-\begin{code}
+import GHCbase
type SampleVar a
type SampleVar a
- = _MVar (Int, -- 1 == full
+ = MVar (Int, -- 1 == full
-- 0 == empty
-- <0 no of readers blocked
-- 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
newSampleVar :: IO (SampleVar a)
newSampleVar
@@
-61,12
+52,6
@@
emptySampleVar v
else
putMVar v (readers,var)
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.
--
-- 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)
_ ->
putMVar val v >>
putMVar svar (min 1 (readers+1), val)
-
-\end{code}