stm-firehose-0.1.2: Conduits and STM operations for fire hoses.

Safe HaskellSafe-Inferred

Control.Concurrent.STM.Firehose

Synopsis

Documentation

newFirehose :: STM (Firehose a)Source

Creates a new Firehose item.

writeEvent :: Firehose a -> a -> STM ()Source

Sends a piece of data in the fire hose.

subscribeSource

Arguments

:: Int

Number of elements buffered. If set too high, it will increase memory usage. If set too low, activity spikes will result in message loss.

-> Firehose a 
-> STM (Subscription a) 

Get a subscription from the fire hose, that will be used to read events.

unsubscribe :: Subscription a -> STM ()Source

Unsubscribe from the fire hose. Subsequent calls to readEvent will return Nothing. This runs in O(n), where n is the current number of subscriptions.

readEvent :: Subscription a -> STM (Maybe a)Source

Read an event from a Subscription. This will return Nothing if the firehose is shut, or the subscription removed.

getQueue :: Subscription a -> TBMQueue aSource

Gets the underlying queue from a subscription.