- data BTChan a
- newBTChan :: Int -> STM (BTChan a)
- newBTChanIO :: Int -> IO (BTChan a)
- writeBTChan :: BTChan a -> a -> STM ()
- readBTChan :: BTChan a -> STM a
- tryWriteBTChan :: BTChan a -> a -> STM Bool
- tryReadBTChan :: BTChan a -> STM (Maybe a)
- unGetBTChan :: BTChan a -> a -> STM ()
- isEmptyBTChan :: BTChan a -> STM Bool
- sizeOfBTChan :: BTChan a -> STM Int
- setMaxOfBTChan :: BTChan a -> Int -> BTChan a
- maxOfBTChan :: BTChan a -> Int
Documentation
newBTChanIO :: Int -> IO (BTChan a)Source
An IO version of newBTChanIO
. This should be useful with unsafePerformIO
in the same manner as newTVarIO
and newTChanIO
are used.
writeBTChan :: BTChan a -> a -> STM ()Source
Writes the value to the BTChan
or blocks if the channel is full.
readBTChan :: BTChan a -> STM aSource
Reads the next value from the BTChan
tryWriteBTChan :: BTChan a -> a -> STM BoolSource
tryReadBTChan :: BTChan a -> STM (Maybe a)Source
A non-blocking read that returns 'Just a' on success and Nothing
when the channel is empty.
unGetBTChan :: BTChan a -> a -> STM ()Source
setMaxOfBTChan :: BTChan a -> Int -> BTChan aSource
let c2 = setMaxOfBTChan c1 mx
Using the same underlying TChan
,
set a new maximum number of messages, mx
. If the current size
is greater than mx
then no messages are dropped, but writes
will block till the size goes lower than mx
. Using c2
and
c1
concurrently is possible, but c2
writes will block at the new
maximum while writes to c1
will block at the new, making it biased
against whichever writer has the channel with the smaller bound.
maxOfBTChan :: BTChan a -> IntSource
Get the bound of the BTChan
.