entwine-0.0.4: entwine - Concurrency tools

Safe HaskellNone
LanguageHaskell98

Entwine.Parallel

Contents

Synopsis

Types

data RunError a Source #

Instances
Show a => Show (RunError a) Source # 
Instance details

Defined in Entwine.Parallel

Methods

showsPrec :: Int -> RunError a -> ShowS #

show :: RunError a -> String #

showList :: [RunError a] -> ShowS #

Functions

consume :: MonadIO m => (Queue b -> IO a) -> Natural -> (b -> IO (Either e c)) -> m (Either (RunError e) (a, [c])) Source #

Provide a producer and an action to be run across the results of that producer in parallel and collect the results. For a version that ignores the results see consume_.

Common usage:

    let producer :: Address -> Queue Address -> IO Int
        producer prefix q =
          list' prefix $$ writeQueue q

    consume producer 100 ((a :: Address) -> doThis)
 

consume_ :: MonadIO m => (Queue b -> IO a) -> Natural -> (b -> EitherT e IO ()) -> EitherT (RunError e) m a Source #

Provide a producer and an action to be run across the result of that producer in parallel. For a version that doesn't ignore the results see consume.

Common usage:

    let producer :: Address -> Queue Address -> IO ()
        producer prefix q =
          list' prefix $$ writeQueue q

    consume producer 100 ((a :: Address) -> doThis)
  

waitEitherBoth :: Async a -> Async b -> Async c -> IO (Either a (b, c)) Source #