| Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> , Roel van Dijk <vandijk.roel@gmail.com> |
|---|
Control.Concurrent.Broadcast
Description
A Broadcast variable is a mechanism for communication between threads. Multiple reader threads can wait until a broadcaster thread writes a signal. The readers block until the signal is received. When the broadcaster sends the signal all readers are woken.
All functions are exception safe. Throwing asynchronous exceptions will not
compromise the internal state of a Broadcast variable.
This module is designed to be imported qualified. We suggest importing it like:
import Control.Concurrent.Broadcast ( Broadcast ) import qualified Control.Concurrent.Broadcast as Broadcast ( ... )
Documentation
A broadcast variable. It can be thought of as a box, which may be empty of full.
newWritten :: α -> IO (Broadcast α)Source
Create a new Broadcast variable containing an initial value.
readTimeout :: Broadcast α -> Integer -> IO (Maybe α)Source
Read the value of a Broadcast variable if it is available within a given
amount of time.
Like read, but with a timeout. A return value of Nothing indicates a timeout
occurred.
The timeout is specified in microseconds. A timeout of 0 μs will cause
the function to return Nothing without blocking in case the Broadcast was
empty. Negative timeouts are treated the same as a timeout of 0 μs.