on master help sign in
update README and Changelog
b9bfd20Harendra Kumar
Changelog.md+4−3
@@ -2,18 +2,19 @@
2
2
3### Bug Fixes
3### Bug Fixes
4
4
5+* Leftover threads are now cleaned up as soon as the SVar is garbage
6+ collected.
5* Fix a bug in concurrent function application that in certain cases would
7* Fix a bug in concurrent function application that in certain cases would
6 unnecessarily share the concurrency state resulting in incorrect output
8 unnecessarily share the concurrency state resulting in incorrect output
7 stream.
9 stream.
8−* Leftover threads are now cleaned up as soon as the SVar is garbage
9− collected.
10* Fix passing of state across parallel, async, wAsync, ahead, serial, wSerial
10* Fix passing of state across parallel, async, wAsync, ahead, serial, wSerial
11 combinators. Without this fix combinators that rely on state passing e.g.
11 combinators. Without this fix combinators that rely on state passing e.g.
12 `maxThreads` and `maxBuffer` won't work across these combinators.
12 `maxThreads` and `maxBuffer` won't work across these combinators.
13
13
14### Enhancements
14### Enhancements
15
15
16+* Added rate limiting combinators `rate`, `avgRate`, `minRate`, `maxRate` and
16−* Added rate limiting combinator `rate` to control the yield rate of a stream.
17+ `constRate` to control the yield rate of a stream.
17* Add `foldl1'`, `foldr1`, `intersperseM`, `find`, `lookup`, `and`, `or`,
18* Add `foldl1'`, `foldr1`, `intersperseM`, `find`, `lookup`, `and`, `or`,
18 `findIndices`, `findIndex`, `elemIndices`, `elemIndex`, `init` to Prelude
19 `findIndices`, `findIndex`, `elemIndices`, `elemIndex`, `init` to Prelude
19
20
README.md+22
@@ -307,6 +307,28 @@ The concurrency facilities provided by streamly can be compared with
307[Cilk](https://en.wikipedia.org/wiki/Cilk) but with a more declarative
307[Cilk](https://en.wikipedia.org/wiki/Cilk) but with a more declarative
308expression.
308expression.
309
309
310+## Rate Limiting
311+
312+For bounded concurrent streams, stream yield rate can be specified. For
313+example, to print hello once every second you can simply write this:
314+
315+``` haskell
316+import Streamly
317+import Streamly.Prelude as S
318+
319+main = runStream $ asyncly $ avgRate 1 $ S.repeatM $ putStrLn "hello"
320+```
321+
322+For some practical uses of rate control, see
323+[AcidRain.hs](https://github.com/composewell/streamly/tree/master/examples/AcidRain.hs)
324+and
325+[CirclingSquare.hs](https://github.com/composewell/streamly/tree/master/examples/CirclingSquare.hs)
326+.
327+Concurrency of the stream is automatically controlled to match the specified
328+rate. Rate control works precisely even at throughputs as high as millions of
329+yields per second. For more sophisticated rate control see the haddock
330+documentation.
331+
310## Reactive Programming (FRP)
332## Reactive Programming (FRP)
311
333
312Streamly is a foundation for first class reactive programming as well by virtue
334Streamly is a foundation for first class reactive programming as well by virtue