rolling-queue

Bounded channel for STM that discards old entries when full

https://github.com/joeyadams/haskell-rolling-queue

Latest on Hackage:0.1

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD-3-Clause licensed by Joey Adams
Maintained by [email protected]

This package provides a FIFO channel for STM supporting a size limit. When this limit is reached, older entries are discarded to make way for newer entries.

The motivation for this is logging. If log entries are written to a plain TChan, the program will use a lot of memory if it produces log entries faster than they can be processed. If log entries are written to a bounded channel where writes block (e.g. the stm-chans package), the program may deadlock if the log channel fills up. With Data.STM.RollingQueue, old entries will be discarded instead.

Possible improvements (not available in Data.STM.RollingQueue) include:

  • Discard lower-priority entries first.

  • Discard every other entry, so some of the older entries will still be available.