| Copyright | (c) 2017 Composewell Technologies |
|---|---|
| License | BSD-3-Clause |
| Maintainer | streamly@composewell.com |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
Streamly.Internal.Data.Stream.SVar.Generate
Contents
Description
Synopsis
- toSVar :: MonadAsync m => SVar SerialT m a -> SerialT m a -> m ()
- fromSVar :: MonadAsync m => SVar Stream m a -> SerialT m a
- fromSVarD :: MonadAsync m => SVar t m a -> Stream m a
Write to SVar
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.