hoare
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.TBCQueue

Description

A closeable, bounded STM queue.

Synopsis

Documentation

data TBCQueue a Source #

Instances

Instances details
Channel TBCQueue Source # 
Instance details

Defined in Control.Concurrent.Channel

newTBCQueueIO :: Natural -> IO (TBCQueue a) Source #

atomically . newTBCQueue

readTBCQueue :: TBCQueue a -> STM (Maybe a) Source #

Returns Just value until the queue is closed, blocking for the next value.

writeTBCQueue :: TBCQueue a -> a -> STM Bool Source #

Writes the given value to the queue if it's still open.

Returns whether the queue is still open so producers know when consumers no longer care.

closeTBCQueue :: TBCQueue a -> STM () Source #

Closes the queue so that future writes are no-ops and readers get Nothing once all previously-written values are read.

lengthTBCQueue :: TBCQueue a -> STM Natural Source #

The number of items currently in the queue.

It is obviously racy to use this value outside the current STM transaction.