|
Control.Concurrent.TxEvent | Portability | non-portable (requires STM) | Stability | experimental | Maintainer | mfluet@acm.org |
|
|
|
|
|
Description |
Transactional Events.
This library provides first-class synchronous events in the style
of CML (http://cml.cs.uchicago.edu/), but generalizes the concept
to allow multiple, dependent events to be combined in a single
event. The semantics of these generalized events ensures an
all-or-nothing transactional property -- either all of the
constituent events synchronize or none of them synchronize. When
the constituent events include synchronous message passing, the
semantics ensures that no thread is able to complete its
synchronization until all of its (transitive) communications
partners are willing to commit to a compatible synchronization.
|
|
Synopsis |
|
|
|
|
Event type
|
|
data Evt a |
A value of type Evt a is an event which, when synchronized upon,
performs some synchronous operations before returning a value of type
a.
When synchronized upon, the event may perform (tentative) synchronous
message passing, but will exhibit no observable effects (i.e., will
not return) until the event and all communication partners can commit.
Evt is a monad (with plus), so Evt actions can be combined using
either the do-notation or the operations from the Monad and
MonadPlus classes.
| Instances | |
|
|
Synchronization
|
|
sync :: Evt a -> IO a |
Synchronize on an event.
|
|
Monadic event combinators
|
|
alwaysEvt :: a -> Evt a |
The always commitable event computation;
the return of the Evt monad.
|
|
thenEvt :: Evt a -> (a -> Evt b) -> Evt b |
Sequential composition of event computations;
the >>= of the Evt monad.
|
|
neverEvt :: Evt a |
The never commitable event computation;
the mzero of the Evt monad.
|
|
chooseEvt :: Evt a -> Evt a -> Evt a |
Non-deterministic composition of event compuations;
the mplus of the Evt monad.
|
|
Exceptions
|
|
throwEvt :: Exception -> Evt a |
A variant of throw that can be used within the Evt monad.
|
|
catchEvt :: Evt a -> (Exception -> Evt a) -> Evt a |
Exception handling within event computations.
|
|
Synchronous channels
|
|
data SChan a |
A SChan is a synchronous channel, used for communication between
concurrent threads. Message passing is synchronous: both the sender
and the receiver must be ready to communicate before either can
proceed.
| Instances | |
|
|
newSChan :: Evt (SChan a) |
Create a new synchronous channel.
|
|
sendEvt :: SChan a -> a -> Evt () |
Send a value on the channel.
|
|
recvEvt :: SChan a -> Evt a |
Receive a value on the channel.
|
|
Time delays
|
|
timeOutEvt :: Int -> Evt () |
Create an event that becomes commitable in the given number of
microseconds after synchronization.
|
|
timeDiffEvt :: TimeDiff -> Evt () |
Create an event that becomes commitable at the specified time interval
after synchronization.
|
|
clockTimeEvt :: ClockTime -> Evt () |
Create an event that becomes commitable at the specified time.
|
|
Miscellaneous
|
|
myThreadIdEvt :: Evt ThreadId |
An always commiable event computation that returns the ThreadId of
the synchronizing thread.
|
|
Produced by Haddock version 0.7 |