Skip to content
Snippets Groups Projects
Commit dce7bd6a authored by sof's avatar sof
Browse files

[project @ 1999-01-25 10:26:18 by sof]

Added isEmptyChan
parent dd52974e
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@ module Channel
dupChan, -- :: Chan a -> IO (Chan a)
unGetChan, -- :: Chan a -> a -> IO ()
isEmptyChan, -- :: Chan a -> IO Bool
{- stream interface -}
getChanContents, -- :: Chan a -> IO [a]
writeList2Chan -- :: Chan a -> [a] -> IO ()
......@@ -96,6 +98,14 @@ unGetChan (Chan read write) val = do
putMVar new_read_end (ChItem val read_end)
putMVar read new_read_end
isEmptyChan :: Chan a -> IO Bool
isEmptyChan (Chan read write) = do
r <- takeMVar read
w <- readMVar write
let eq = r == w
eq `seq` putMVar read r
return eq
\end{code}
Operators for interfacing with functional streams.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment