Skip to content

Commit

Permalink
Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgf committed Mar 1, 2011
1 parent 66237ca commit 1fc2d2a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Control/Concurrent/Barrier.hs
Expand Up @@ -21,21 +21,23 @@ barrier' reset count = do

maybe (return ()) takeMVar w

-- | Self-resetting barrier. 'barrier' blocks until 'count' threads hit
-- it, and then they are all allowed to run. The barrier is then
-- reset so that a further 'count' threads can block on it.
-- Typical usage is:
-- | Self-resetting barrier. 'barrier' blocks until a specified
-- number of threads have reached it, and then they are all allowed to
-- run. The barrier is then reset so that a further 'count' threads
-- can block on it. Typical usage is:
--
-- > do b <- barrier 3
-- > forkIO $ b >> putStrLn "1" -- blocked
-- > forkIO $ b >> putStrLn "2" -- blocked
-- > forkIO $ b >> putStrLn "3" -- all three threads run
barrier :: Int -> IO (IO ())
barrier :: Int -- ^ count - number of threads required before barrier is opened
-> IO (IO ())
barrier = barrier' id

-- | Latching barrier. This is the same as 'barrier', except once the
-- barrier has opened (the requisite number of threads has reached
-- it), it remains open, allowing all subsequent threads through
-- unblocked.
latchBarrier :: Int -> IO (IO ())
latchBarrier = barrier' (\_ -> 0)
latchBarrier :: Int -- ^ count - number of threads required before barrier is opened
-> IO (IO ())
latchBarrier = barrier' (const 0)

0 comments on commit 1fc2d2a

Please sign in to comment.