Portability | not portable (requires STM) |
---|---|
Stability | unstable |
Maintainer | paolo.veronelli@gmail.com |
Safe Haskell | None |
Synchronized execution of sequences of actions, controlled in STM
All data structures are made accessible via Data.Lens abstraction.
Actions to be executed are of type Action
= STM (IO ()). At each tick, the scheduled actions are ordered by priority,
binded as STM actions ignoring the retrying ones. The results, being IO actions are executed in that order.
Every Track
and Metronome
lives in its own thread and can be stopped or killed as such, setting a flag in its state.
Track and metronome state are exposed in TVar value to be modified at will. The only closed and inaccessible value is the synchronizing channel,
written by the metronome and waited by tracks.
The TrackForker
returned by a metronome function is closing this channel and it's the only way to fork a track.
See System.Metronome.Practical for an simple wrapper around this module.
- data Track = Track {}
- data Thread a = Thread {}
- data Metronome = Metronome {}
- sync :: Lens Track Ticks
- frequency :: Lens Track Frequency
- actions :: Lens Track [Action]
- priority :: Lens Track Priority
- muted :: Lens Track Bool
- running :: forall a. Lens (Thread a) Bool
- alive :: forall a. Lens (Thread a) Bool
- core :: forall a. Lens (Thread a) a
- ticks :: Lens Metronome [MTime]
- schedule :: Lens Metronome [(Priority, Action)]
- type Control a = TVar (Thread a)
- type Priority = Double
- type Frequency = Integer
- type Ticks = Integer
- type Action = STM (IO ())
- type MTime = Double
- type TrackForker = Control Track -> IO ()
- metronome :: Control Metronome -> IO TrackForker
Data structures
State of a track.
Track | |
|
State of a metronome
Lenses
Synonyms
type Action = STM (IO ())Source
Track effect interface. Write in STM the collective and spit out the IO action to be executed when all STMs for this tick are done or retried