An event is in one of two possible states: "set" or "cleared".
Moduleconcurrent-extra-0.7.0.12Haskell98
Control.Concurrent.Event
An Event is a simple mechanism for communication between threads: one thread signals an event and other threads wait for it.
An event has a state which is either "set" or "cleared". This state can be changed with the corresponding functions set and clear. The wait function blocks until the state is "set". An important property of setting an event is that all threads waiting for it are woken.
It was inspired by the Python Event object. See:
http://docs.python.org/3.1/library/threading.html#event-objects
This module is designed to be imported qualified. We suggest importing it like:
import Control.Concurrent.Event ( Event )
import qualified Control.Concurrent.Event as Event ( ... )
- 1 type
- 8 values
- Packageconcurrent-extra-0.7.0.12
- Exports9
- LanguageHaskell98
- LicenceBSD-3-Clause
- SourceEvent.hs
Creating events
2 declarationsCreate an event in the "cleared" state.
Create an event in the "set" state.
Waiting for events
3 declarationsBlock until the event is set or until a timer expires.
Like wait, but with a timeout. A return value of False indicates a timeout occurred.
The timeout is specified in microseconds.
If the event is "cleared" and a timeout of 0 μs is specified the function returns False without blocking.
Negative timeouts are treated the same as a timeout of 0 μs.
Setting events
3 declarationsChanges the state of the event to "set". All threads that where waiting for this event are woken. Threads that wait after the state is changed to "set" will not block at all.
Changes the state of the event to "cleared". Threads that wait after the state is changed to "cleared" will block until the state is changed to "set".