caf-0.0.3: A library of Concurrency Abstractions using Futures.

Portabilitynon-portable (requires Futures)
Stabilityexperimental
Maintainerwillig@ki.informatik.uni-frankfurt.de

Control.Concurrent.Futures.BChan

Description

This modules combines a quantity semaphore from the module Control.Concurrent.Fututes.QSem and a channel from module Control.Concurrent.Fututes.Chan to a new synchronisation primitive. Bounded channels have a limited capacity of storage cells. Warning: All operations on bounded channels should only be used within the global wrapper function Futures.withFuturesDo!

Synopsis

Documentation

type BChan a = (Chan a, QSem)Source

newBChan :: Int -> IO (BChan a)Source

Creates a new bounded channel

readBChan :: BChan a -> IO aSource

Performs an up-operation on the QSem of the bounded channel and then reads a value from the channel. The read operation may block.

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

Performs a down-operations on the QSem of the bounded channel and writes a new value to it. The down-operation may block.