[Haskell-cafe] SampleVar semantics, documentation vs. source

Eric Stansifer eric.stansifer+haskell at gmail.com
Thu Dec 30 06:03:44 CET 2010


Hi,

doc:  http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/base-4.3.0.0/Control-Concurrent-SampleVar.html
source:  http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/base-4.3.0.0/src/Control-Concurrent-SampleVar.html

The documentation for Control.Concurrent.SampleVar implies that a
SampleVar is either "filled" or "empty".  The source code suggests
that there are three possible states:  "full" (when readers == 1),
"empty" (when readers == 0), and "empty with blocked readers" (when
readers < 0).  In particular, the isEmptySampleVar function,

isEmptySampleVar :: SampleVar a -> IO Bool
isEmptySampleVar (SampleVar svar) = do
  (readers, _) <- readMVar svar
  return (readers == 0)

returns false in the third state, when readers < 0.  Can someone
clarify the semantics of SampleVar?

Thanks,
Eric



More information about the Haskell-Cafe mailing list