streamly-0.8.1.1: Dataflow programming and declarative concurrency
Copyright(c) 2017 Composewell Technologies
LicenseBSD-3-Clause
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.Data.Stream.SVar.Generate

Description

 
Synopsis

Write to SVar

toSVar :: MonadAsync m => SVar SerialT m a -> SerialT m a -> m () Source #

Write a stream to an SVar in a non-blocking manner. The stream can then be read back from the SVar using fromSVar.

Read from SVar

Usually the SVar is used to concurrently evaluate multiple actions in a stream using many worker threads that push the results to the SVar and a single puller that pulls them from SVar generating the evaluated stream.

                 input stream
                      |
    <-----------------|<--------worker
    |  exceptions     |
output stream <------SVar<------worker
                      |
                      |<--------worker

The puller itself schedules the worker threads based on demand. Exceptions are propagated from the worker threads to the puller.

fromSVar :: MonadAsync m => SVar Stream m a -> SerialT m a Source #

Generate a stream from an SVar. An unevaluated stream can be pushed to an SVar using toSVar. As we pull a stream from the SVar the input stream gets evaluated concurrently. The evaluation depends on the SVar style and the configuration parameters e.g. using the maxBuffer/maxThreads combinators.

fromSVarD :: MonadAsync m => SVar t m a -> Stream m a Source #

Like fromSVar but generates a StreamD style stream instead of CPS.