orderly-workers-0.1.0.0: Fork concurrent worker threads and produce ordered results

Safe HaskellSafe
LanguageHaskell2010

Control.Concurrent.OrderlyWorkers

Description

You can imagine the workers as a room full of translators, who you pass pages in to in one language and expect translated pages to come out the other side. You'll get faster results if there's more than one translator in the room, but you still need the pages to come out the other side in the order their equivalents came in.

You want the benefits of multiple translators working at the same time, but you don't want to or have the ability to hold all the pages in memory and sort them after the fact.

forkOrderlyWorkers could be compared to mapConcurrently from async except you don't need to hold all input or output values in memory as a list.

Synopsis

Documentation

forkOrderlyWorkers :: Int -> (input -> IO output) -> IO (Maybe input) -> (output -> IO ()) -> IO () Source #

Nothing for the producer indicates there's no more input.

forkOrderlyWorkers doesn't return until the producer has returned a Nothing and all the remaining Just values have been processed and their values given to the consumer. In other words, until all the work has been done.