Skip to content

SamuelSchlesinger/stm-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Concurrent Real-Time Queue

Hackage Build Status

This is an implementation of a real-time queue using STM. It has lower throughput than TQueue but much lower latency as well. It does not support an equivalent to unGetTQueue, but could be made to likely if someone needs it. Here's an example:

main :: IO ()
main = do
  q <- atomically do
    q <- atomically newQueue
    forM_ [1..1000] (enqueue q)
  consumer q

consumer :: Queue Int -> IO ()
consumer q = forever do
  i <- atomically (dequeue q)
  print i

It also supports peek, which looks at the next element of the Queue. For each operation except for enqueue, there is a try prefixed version which does not do an stm retry upon failure.

About

A real-time concurrent queue

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published