-----------------------------------------------------------------------------
module Control.Concurrent.QSemN
- ( -- * General Quantity Semaphores
- QSemN, -- abstract
- newQSemN, -- :: Int -> IO QSemN
- waitQSemN, -- :: QSemN -> Int -> IO ()
- signalQSemN -- :: QSemN -> Int -> IO ()
+ ( -- * General Quantity Semaphores
+ QSemN, -- abstract
+ newQSemN, -- :: Int -> IO QSemN
+ waitQSemN, -- :: QSemN -> Int -> IO ()
+ signalQSemN -- :: QSemN -> Int -> IO ()
) where
import Prelude
free avail [] = return (avail,[])
free avail ((req,block):blocked)
| avail >= req = do
- putMVar block ()
- free (avail-req) blocked
+ putMVar block ()
+ free (avail-req) blocked
| otherwise = do
- (avail',blocked') <- free avail blocked
+ (avail',blocked') <- free avail blocked
return (avail',(req,block):blocked')
module Control.Concurrent.SampleVar
(
- -- * Sample Variables
+ -- * Sample Variables
SampleVar, -- :: type _ =
- newEmptySampleVar, -- :: IO (SampleVar a)
+ newEmptySampleVar, -- :: IO (SampleVar a)
newSampleVar, -- :: a -> IO (SampleVar a)
- emptySampleVar, -- :: SampleVar a -> IO ()
- readSampleVar, -- :: SampleVar a -> IO a
- writeSampleVar, -- :: SampleVar a -> a -> IO ()
- isEmptySampleVar, -- :: SampleVar a -> IO Bool
+ emptySampleVar, -- :: SampleVar a -> IO ()
+ readSampleVar, -- :: SampleVar a -> IO a
+ writeSampleVar, -- :: SampleVar a -> a -> IO ()
+ isEmptySampleVar, -- :: SampleVar a -> IO Bool
) where
-- (different from 'putMVar' on full 'MVar'.)
type SampleVar a
- = MVar (Int, -- 1 == full
- -- 0 == empty
- -- <0 no of readers blocked
+ = MVar (Int, -- 1 == full
+ -- 0 == empty
+ -- <0 no of readers blocked
MVar a)
-- |Build a new, empty, 'SampleVar'