Control.Concurrent.CHP.Traces
Description
A module that re-exports all the parts of the library related to tracing.
The idea of tracing is to record the concurrent events (i.e. channel communications and barrier synchronisations) that occur during a run of the program. You can think of it as automatically turning on a lot of debug logging.
Typically, at the top-level of your program you should have:
main :: IO () main = runCHP myMainProcess
To turn on the tracing mechanism of your choice (for example, CSP-style tracing) to automatically print out the trace after completion of your program, just use the appropriate helper function:
main :: IO () main = runCHP_CSPTraceAndPrint myMainProcess
It could hardly be easier. If you want more fine-grained control and examination
of the trace, you can use the helper functions of the form runCHP_CSPTrace
that give back a data structure representing the trace, which you can then
manipulate. The Doc used by the traces is from the Text.PrettyPrint.HughesPJ
module that currently comes with GHC (I think).
- module Control.Concurrent.CHP.Traces.CSP
- module Control.Concurrent.CHP.Traces.Structural
- module Control.Concurrent.CHP.Traces.TraceOff
- module Control.Concurrent.CHP.Traces.VCR
- data RecordedEvent
- data RecordedIndivEvent
- class Show t => Trace t where
- runCHPAndTrace :: CHP a -> IO (Maybe a, t)
- emptyTrace :: t
- prettyPrint :: t -> Doc
Documentation
data RecordedEvent Source
A globally recorded event, found in CSP and VCR traces. Either a channel communication (with a unique identifier of the channel) or a barrier synchronisation (with a unique identifier of the barrier). The identifiers are per channel/barrier, not per event. Currently, channels and barriers can never have the same Unique as each other, but do not rely on this behaviour.
Constructors
ChannelComm Unique | |
BarrierSync Unique |
Instances
data RecordedIndivEvent Source
An individual record of an event, found in nested traces. Either a channel write or read, or a barrier synchronisation, each with a unique identifier for the barrier/channel. The event will be recorded by everyone involved, and a ChannelWrite will have the same channel identifier as the corresponding channel-read. The identifiers are per channel/barrier, not per event. Currently, channels and barriers can never have the same Unique as each other, but do not rely on this behaviour.
Constructors
ChannelWrite Unique | |
ChannelRead Unique | |
BarrierSyncIndiv Unique |
Instances
class Show t => Trace t whereSource
A class representing a type of trace. The main useful function is runCHPAndTrace
,
but because its type is only determined by its return type, you may wish
to use the already-typed functions offered in each trace module -- see the
modules in Control.Concurrent.CHP.Traces.
Methods
runCHPAndTrace :: CHP a -> IO (Maybe a, t)Source
Runs the given CHP program, and returns its return value and the trace. The return value is a Maybe type because the process may have exited due to uncaught poison. In that case Nothing is return as the result.
emptyTrace :: tSource
The empty trace.
prettyPrint :: t -> DocSource
Pretty-prints the given trace using the Text.PrettyPrint.HughesPJ module.