stm-queue-0.2.0.0: An implementation of a real-time concurrent queue
Copyright(c) Samuel Schlesinger 2020
LicenseMIT
Maintainersgschlesinger@gmail.com
Stabilityexperimental
PortabilityPOSIX, Windows
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Queue

Description

 
Synopsis

Documentation

data Queue a Source #

Real time Queue backed by transactional variables (TVars)

newQueue :: STM (Queue a) Source #

Create a new, empty Queue

peek :: Queue a -> STM a Source #

Peek at the top of the Queue, returning the top element.

tryPeek :: Queue a -> STM (Maybe a) Source #

Try to peek for the top item of the Queue. This function is offered to easily port from the TQueue offered in the stm package, but is not the intended usage of the library.

enqueue :: Queue a -> a -> STM () Source #

Enqueue a single item onto the Queue.

dequeue :: Queue a -> STM a Source #

Dequeue a single item onto the Queue, retrying if there is nothing there. This is the motivating use case of this library, allowing a thread to register its interest in the head of a Queue and be woken up by the runtime system to read from the top of that Queue when an item has been made available.

tryDequeue :: Queue a -> STM (Maybe a) Source #

Try to dequeue a single item. This function is offered to allow users to easily port from the TQueue offered in the stm package, but is not the intended usage of the library.

flush :: Queue a -> STM [a] Source #

Efficiently read the entire contents of a Queue into a list.