caf-0.0.3: A library of Concurrency Abstractions using Futures.

Portabilitynon-portable (requires Futures)



This module implements barrier using futures. A rendezvous ensures that two threads meet at a specific point before continuing their computation. The rendezvous idiom blocks at this point until both threads have arrived. A barrier is a rendezvous for a group of processes. Assume that a application is divided into phases where a couple of threads compute several interims to be the input for the next phase. Then all threads must complete the current phase before entering the next. To achieve this behaviour a barrier is placed at the end of a phase. Note that a barriers is purely for synchronisation and not for exchange of data.

Warning: All operations on barrier should only be used within the global wrapper function withFuturesDo!



type Bar a = (Buffer a, Buffer [Bool -> IO ()], Int)Source

A new barrier type contains of a buffer containing the count of active threads, a buffer containing the a count of finished threads and a capacity.

newBar :: Int -> IO (Buffer Int, Buffer [Bool -> IO ()], Int)Source

Creates a new barrier.

syncBar :: (Buffer Int, Buffer [Bool -> IO ()], Int) -> IO BoolSource

syncs on the barrier