|Maintainer||Bas van Dijk <firstname.lastname@example.org> , Roel van Dijk <email@example.com>|
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
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 ( ... )
A broadcast variable. It can be thought of as a box, which may be empty of full.
Create a new
Broadcast variable containing an initial value.
Read the value of a
Broadcast variable if it is available within a given
amount of time.
The timeout is specified in microseconds. A timeout of 0 μs will cause
the function to return
Nothing without blocking in case the
empty. Negative timeouts are treated the same as a timeout of 0 μs.
Write a new value into a
If the variable is empty any threads that are reading from the variable will be woken. If the variable is full its contents will simply be overwritten.