shellmate-0.3.2.2: Simple interface for shell scripting in Haskell.

Safe HaskellNone
LanguageHaskell2010

Control.Shell.Concurrent

Description

Concurrency for Shellmate programs.

Synopsis

Documentation

data Future a Source #

A future is a computation which is run in parallel with a program's main thread and which may at some later point finish and return a value.

Note that future computations are killed when their corresponding Future is garbage collected. This means that a future should *always* be awaited at some point or otherwise kept alive, to ensure that the computation finishes.

Note that all any code called in a future using unsafeLiftIO must refrain from using environment variables, standard input/output, relative paths and the current working directory, in order to avoid race conditions. Code within the Shell monad, code imported using liftIO and external processes spawned from within Shell is perfectly safe.

future :: Shell a -> Shell (Future a) Source #

Create a future value.

await :: Future a -> Shell a Source #

Wait for a future value.

check :: Future a -> Shell (Maybe a) Source #

Check whether a future value has arrived or not.

parallel :: [Shell a] -> Shell [a] Source #

Perform the given computations in parallel. The race condition warning for Future when modifying environment variables or using relative paths still applies.

parallel_ :: [Shell a] -> Shell () Source #

Like parallel, but discards any return values.

chunks :: Int -> [a] -> [[a]] Source #

Break a list into chunks. This is quite useful for when performing *every* computation in parallel is too much. For instance, to download a list of files three at a time, one would do mapM_ (parallel_ downloadFile) (chunks 3 files).