concurrent-barrier-0.1.2: Simple thread barriers

Control.Concurrent.Barrier

Synopsis

Documentation

barrierSource

Arguments

:: Int

count - number of threads required before barrier is opened

-> IO Barrier 

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

latchBarrierSource

Arguments

:: Int

count - number of threads required before barrier is opened

-> IO Barrier 

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.