brick-0.52.1: A declarative terminal user interface library

Safe Haskell | Safe
Language | Haskell2010

Brick.BChan

Synopsis

- data BChan a
- newBChan :: Int -> IO (BChan a)
- writeBChan :: BChan a -> a -> IO ()
- writeBChanNonBlocking :: BChan a -> a -> IO Bool
- readBChan :: BChan a -> IO a
- readBChan2 :: BChan a -> BChan b -> IO (Either a b)

# Documentation

data BChan a Source #

`BChan` is an abstract type representing a bounded FIFO channel.

newBChan Source #

Arguments

:: Int | maximum number of elements the channel can hold
-> IO (BChan a) |

Builds and returns a new instance of `BChan`.

writeBChan :: BChan a -> a -> IO () Source #

Writes a value to a `BChan`; blocks if the channel is full.

writeBChanNonBlocking :: BChan a -> a -> IO Bool Source #

Attempts to write a value to a `BChan`. If the channel has room, the value is written and this returns `True`. Otherwise this returns `False` and returns immediately.

readBChan :: BChan a -> IO a Source #

Reads the next value from the `BChan`; blocks if necessary.

readBChan2 :: BChan a -> BChan b -> IO (Either a b) Source #

Reads the next value from either `BChan`, prioritizing the first `BChan`; blocks if necessary.